Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/workflows/pr-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.


2 changes: 1 addition & 1 deletion lambda-layer/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
build

# Ignore Terraform state files
.terraform
.terraform/
*.tfstate
*.tfstate.backup
*.lock.hcl
15 changes: 10 additions & 5 deletions lambda-layer/build-layer.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
set -e

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

Expand Down Expand Up @@ -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
Expand All @@ -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
2 changes: 1 addition & 1 deletion lambda-layer/otel-instrument
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
Loading