Skip to content
Merged
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
6 changes: 6 additions & 0 deletions lambda-layer/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@

# Ignore Gradle build output directory
build

# Ignore Terraform state files
.terraform
*.tfstate
*.tfstate.backup
*.lock.hcl
13 changes: 9 additions & 4 deletions lambda-layer/build-layer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ SOURCEDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"


## Get OTel version
echo "Info: Getting OTEL Version"
file="$SOURCEDIR/../.github/patches/versions"
version=$(awk -F'=v' '/OTEL_JAVA_INSTRUMENTATION_VERSION/ {print $2}' "$file")
echo "Found OTEL Version: ${version}"
Expand All @@ -15,16 +16,17 @@ fi


## Clone and Patch the OpenTelemetry Java Instrumentation Repository
echo "Info: Cloning and Patching OpenTelemetry Java Instrumentation Repository"
git clone https://github.com/open-telemetry/opentelemetry-java-instrumentation.git
pushd opentelemetry-java-instrumentation
git checkout v${version} -b tag-v${version}

# This patch is for Lambda related context propagation
patch -p1 < "$SOURCEDIR"/patches/opentelemetry-java-instrumentation.patch

# There is another patch in the .github/patches directory for other changes. We should apply them too for consistency.
patch -p1 < "$SOURCEDIR"/../.github/patches/opentelemetry-java-instrumentation.patch

# 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"
./gradlew publishToMavenLocal
Expand All @@ -33,16 +35,19 @@ rm -rf opentelemetry-java-instrumentation


## Build the ADOT Java from current source
echo "Info: Building ADOT Java from current source"
pushd "$SOURCEDIR"/..
patch -p1 < "${SOURCEDIR}"/patches/aws-otel-java-instrumentation.patch
CI=false ./gradlew publishToMavenLocal -Prelease.version=${version}-adot-lambda1
popd


## Build ADOT Lambda Java SDK Layer Code
./gradlew build
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
8 changes: 5 additions & 3 deletions lambda-layer/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@ val javaagentDependency by configurations.creating {
extendsFrom()
}

val otelVersion: String by project

dependencies {
compileOnly(platform("io.opentelemetry:opentelemetry-bom:1.32.1"))
compileOnly(platform("io.opentelemetry:opentelemetry-bom-alpha:1.32.1-alpha"))
compileOnly(platform("io.opentelemetry:opentelemetry-bom:$otelVersion"))
compileOnly(platform("io.opentelemetry:opentelemetry-bom-alpha:$otelVersion-alpha"))
// Already included in wrapper so compileOnly
compileOnly("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure-spi")
compileOnly("io.opentelemetry:opentelemetry-sdk-extension-aws")
javaagentDependency("software.amazon.opentelemetry:aws-opentelemetry-agent:1.32.1-adot-lambda1")
javaagentDependency("software.amazon.opentelemetry:aws-opentelemetry-agent:$otelVersion-adot-lambda1")
}

tasks.register<Copy>("download") {
Expand Down
23 changes: 22 additions & 1 deletion lambda-layer/otel-instrument
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,25 @@ else
export OTEL_RESOURCE_ATTRIBUTES="$LAMBDA_RESOURCE_ATTRIBUTES,$OTEL_RESOURCE_ATTRIBUTES";
fi

exec "$@"
ARGS=("$@")
EXTRA_ARGS=()

if [ "${OTEL_JAVA_AGENT_FAST_STARTUP_ENABLED}" == "true" ]; then
echo "[OTEL] Enabling fast startup mode ..."
# Disable bytecode verification
EXTRA_ARGS+=("-Xverify:none")
# Be sure that tiered compilation is enabled
EXTRA_ARGS+=("-XX:+TieredCompilation")
# Stop tiered compilation at level 1
EXTRA_ARGS+=("-XX:TieredStopAtLevel=1")
for i in "${!ARGS[@]}"; do
# If tiered compilation is disabled, ignore it as we enable it at level 1 for fast startup
if [[ ${ARGS[i]} = "-XX:-TieredCompilation" ]]; then
unset 'ARGS[i]'
fi
done
fi

ARGS=("${ARGS[0]}" "${EXTRA_ARGS[@]}" "${ARGS[@]:1}")

exec "${ARGS[@]}"
6 changes: 3 additions & 3 deletions lambda-layer/patches/aws-otel-java-instrumentation.patch
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ index 9493189..6090207 100644
val TEST_SNAPSHOTS = rootProject.findProperty("testUpstreamSnapshots") == "true"

// This is the version of the upstream instrumentation BOM
-val otelVersion = "1.32.1-adot2"
+val otelVersion = "1.32.1-adot-lambda1"
val otelSnapshotVersion = "1.33.0"
-val otelVersion = "1.33.6-adot1"
+val otelVersion = "1.33.6-adot-lambda1"
val otelSnapshotVersion = "1.33.6"
val otelAlphaVersion = if (!TEST_SNAPSHOTS) "$otelVersion-alpha" else "$otelSnapshotVersion-alpha-SNAPSHOT"
val otelJavaAgentVersion = if (!TEST_SNAPSHOTS) otelVersion else "$otelSnapshotVersion-SNAPSHOT"
Original file line number Diff line number Diff line change
Expand Up @@ -636,10 +636,10 @@ index cc1414c0bf..db8a59b046 100644
--- a/version.gradle.kts
+++ b/version.gradle.kts
@@ -1,5 +1,5 @@
-val stableVersion = "1.32.1"
-val alphaVersion = "1.32.1-alpha"
+val stableVersion = "1.32.1-adot-lambda1"
+val alphaVersion = "1.32.1-adot-lambda1-alpha"
-val stableVersion = "1.33.6-adot1"
-val alphaVersion = "1.33.6-adot1-alpha"
+val stableVersion = "1.33.6-adot-lambda1"
+val alphaVersion = "1.33.6-adot-lambda1-alpha"

allprojects {
if (findProperty("otel.stable") != "true") {
Loading