diff --git a/.github/workflows/pr-build.yml b/.github/workflows/pr-build.yml index 507362ddeb..31c9cba7f7 100644 --- a/.github/workflows/pr-build.yml +++ b/.github/workflows/pr-build.yml @@ -156,3 +156,18 @@ jobs: arguments: build --stacktrace -PenableCoverage=true - uses: codecov/codecov-action@v3 + build-lambda: + runs-on: ubuntu-latest + steps: + - name: Checkout Repo @ SHA - ${{ github.sha }} + uses: actions/checkout@v4 + + - name: Setup Java + uses: actions/setup-java@v4 + with: + java-version: 17 + distribution: temurin + + - name: Build layer + working-directory: lambda-layer + run: ./build-layer.sh diff --git a/README.md b/README.md index 4af75998eb..15a34a17b4 100644 --- a/README.md +++ b/README.md @@ -46,3 +46,5 @@ Please note that as per policy, we're providing support via GitHub on a best eff ## Security issue notifications If you discover a potential security issue in this project we ask that you notify AWS/Amazon Security via our [vulnerability reporting page](http://aws.amazon.com/security/vulnerability-reporting/). Please do **not** create a public github issue. + + diff --git a/lambda-layer/.gitignore b/lambda-layer/.gitignore index d79194e8da..719d3e0657 100644 --- a/lambda-layer/.gitignore +++ b/lambda-layer/.gitignore @@ -5,7 +5,7 @@ build # Ignore Terraform state files -.terraform +.terraform/ *.tfstate *.tfstate.backup *.lock.hcl \ No newline at end of file diff --git a/lambda-layer/build-layer.sh b/lambda-layer/build-layer.sh index c1750e4588..f063dac073 100755 --- a/lambda-layer/build-layer.sh +++ b/lambda-layer/build-layer.sh @@ -1,4 +1,5 @@ #!/bin/bash +set -e SOURCEDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" @@ -27,8 +28,8 @@ patch -p1 < "$SOURCEDIR"/../.github/patches/opentelemetry-java-instrumentation.p # This patch is for Lambda related context propagation patch -p1 < "$SOURCEDIR"/patches/opentelemetry-java-instrumentation.patch -git add -A -git commit -m "Create patch version" +#git add -A +#git commit -m "Create patch version" ./gradlew publishToMavenLocal popd rm -rf opentelemetry-java-instrumentation @@ -46,8 +47,12 @@ popd echo "Info: Building ADOT Lambda Java SDK Layer Code" ./gradlew build -PotelVersion=${version} - ## Copy ADOT Java Agent downloaded using Gradle task and bundle it with the Lambda handler script echo "Info: Creating the layer artifact" -cp "$SOURCEDIR"/build/javaagent/aws-opentelemetry-agent*.jar ./opentelemetry-javaagent.jar -zip -qr opentelemetry-javaagent-layer.zip opentelemetry-javaagent.jar otel-instrument +mkdir -p "$SOURCEDIR"/build/distributions/ +cp "$SOURCEDIR"/build/javaagent/aws-opentelemetry-agent*.jar "$SOURCEDIR"/build/distributions/aws-opentelemetry-javaagent.jar +zip -r ./build/distributions/aws-opentelemetry-java-layer.zip "$SOURCEDIR"/build/distributions/aws-opentelemetry-javaagent.jar otel-instrument + +## Cleanup +# revert the patch applied since it is only needed while building the layer. +git restore ../dependencyManagement/build.gradle.kts diff --git a/lambda-layer/otel-instrument b/lambda-layer/otel-instrument index e28a2ea884..915d41d9d0 100644 --- a/lambda-layer/otel-instrument +++ b/lambda-layer/otel-instrument @@ -6,7 +6,7 @@ export OTEL_PROPAGATORS="${OTEL_PROPAGATORS:-xray,tracecontext,b3,b3multi}" export OTEL_SERVICE_NAME=${OTEL_SERVICE_NAME:-${AWS_LAMBDA_FUNCTION_NAME}} -export JAVA_TOOL_OPTIONS="-javaagent:/opt/opentelemetry-javaagent.jar ${JAVA_TOOL_OPTIONS}" +export JAVA_TOOL_OPTIONS="-javaagent:/opt/aws-opentelemetry-javaagent.jar ${JAVA_TOOL_OPTIONS}" if [[ $OTEL_RESOURCE_ATTRIBUTES != *"service.name="* ]]; then export OTEL_RESOURCE_ATTRIBUTES="service.name=${AWS_LAMBDA_FUNCTION_NAME},${OTEL_RESOURCE_ATTRIBUTES}"