Skip to content

Commit e8da80b

Browse files
authored
Merge pull request #2 from srprash/1.33.x_lambda_gh_ci
1.33.x lambda gh ci
2 parents f696f40 + 4fda1fb commit e8da80b

File tree

4 files changed

+25
-5
lines changed

4 files changed

+25
-5
lines changed

.github/workflows/pr-build.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,3 +156,18 @@ jobs:
156156
arguments: build --stacktrace -PenableCoverage=true
157157
- uses: codecov/codecov-action@v3
158158

159+
build-lambda:
160+
runs-on: ubuntu-latest
161+
steps:
162+
- name: Checkout Repo @ SHA - ${{ github.sha }}
163+
uses: actions/checkout@v4
164+
165+
- name: Setup Java
166+
uses: actions/setup-java@v4
167+
with:
168+
java-version: 17
169+
distribution: temurin
170+
171+
- name: Build layer
172+
working-directory: lambda-layer
173+
run: ./build-layer.sh

lambda-layer/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
build
66

77
# Ignore Terraform state files
8-
.terraform
8+
.terraform/
99
*.tfstate
1010
*.tfstate.backup
1111
*.lock.hcl

lambda-layer/build-layer.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/bin/bash
2+
set -e
23

34
SOURCEDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
45

@@ -46,8 +47,12 @@ popd
4647
echo "Info: Building ADOT Lambda Java SDK Layer Code"
4748
./gradlew build -PotelVersion=${version}
4849

49-
5050
## Copy ADOT Java Agent downloaded using Gradle task and bundle it with the Lambda handler script
5151
echo "Info: Creating the layer artifact"
52-
cp "$SOURCEDIR"/build/javaagent/aws-opentelemetry-agent*.jar ./opentelemetry-javaagent.jar
53-
zip -qr opentelemetry-javaagent-layer.zip opentelemetry-javaagent.jar otel-instrument
52+
mkdir -p "$SOURCEDIR"/build/distributions/
53+
cp "$SOURCEDIR"/build/javaagent/aws-opentelemetry-agent*.jar "$SOURCEDIR"/build/distributions/aws-opentelemetry-javaagent.jar
54+
zip -r ./build/distributions/aws-opentelemetry-java-layer.zip "$SOURCEDIR"/build/distributions/aws-opentelemetry-javaagent.jar otel-instrument
55+
56+
## Cleanup
57+
# revert the patch applied since it is only needed while building the layer.
58+
git restore ../dependencyManagement/build.gradle.kts

lambda-layer/otel-instrument

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export OTEL_PROPAGATORS="${OTEL_PROPAGATORS:-xray,tracecontext,b3,b3multi}"
66

77
export OTEL_SERVICE_NAME=${OTEL_SERVICE_NAME:-${AWS_LAMBDA_FUNCTION_NAME}}
88

9-
export JAVA_TOOL_OPTIONS="-javaagent:/opt/opentelemetry-javaagent.jar ${JAVA_TOOL_OPTIONS}"
9+
export JAVA_TOOL_OPTIONS="-javaagent:/opt/aws-opentelemetry-javaagent.jar ${JAVA_TOOL_OPTIONS}"
1010

1111
if [[ $OTEL_RESOURCE_ATTRIBUTES != *"service.name="* ]]; then
1212
export OTEL_RESOURCE_ATTRIBUTES="service.name=${AWS_LAMBDA_FUNCTION_NAME},${OTEL_RESOURCE_ATTRIBUTES}"

0 commit comments

Comments
 (0)