fix(java-wrapper): link wrapper spans to invocation X-Ray trace - #1139
Merged
priyankaDhingra merged 1 commit intoAug 3, 2026
Merged
Conversation
…er system property On managed Java 17+ Lambda runtimes the per-invocation X-Ray trace context is exposed via the com.amazonaws.xray.traceHeader system property rather than the _X_AMZN_TRACE_ID environment variable the OTel Lambda wrapper reads. As a result the SDK wrapper's spans were assigned a fresh X-Ray-compatible trace id (from AwsOtelTracerProviderConfigurer) that was disconnected from the invocation's X-Ray trace, so downstream segments (e.g. S3) never appeared in the invocation trace and soak trace validation failed. Add an AutoConfigurationCustomizerProvider that wraps the configured propagators: event-carrier extraction still takes precedence, but when it yields no valid parent the wrapper falls back to the traceHeader system property and presents it to the already-configured X-Ray propagator as a synthetic X-Amzn-Trace-Id. The property is read per invocation and no new runtime dependency is introduced. Ships only in the wrapper extension jar, so the javaagent layer is unaffected.
priyankaDhingra
marked this pull request as ready for review
August 3, 2026 01:25
alexperez52
approved these changes
Aug 3, 2026
priyankaDhingra
merged commit Aug 3, 2026
0175e87
into
fix/nodejs-soak-otel-v0.151.0
45 of 48 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
On the managed Java 17+ Lambda runtimes, the OTel Lambda wrapper layer's SDK spans were not linked to the enclosing invocation's X-Ray trace. As a result, downstream segments (e.g. the S3
ListBucketscall in the aws-sdk sample app) landed in a separate trace from the invocation's X-Ray trace, and the soakvalidate trace samplestep failed withdata model not matched(the expected S3 subsegment was absent from the invocation trace).Root cause
The managed Java 17+ runtime exposes the per-invocation X-Ray trace context via the
com.amazonaws.xray.traceHeadersystem property, not the_X_AMZN_TRACE_IDenvironment variable that older OTel Lambda instrumentation reads. Because nothing seeded the context from that property, the wrapper root span received a fresh (X-Ray-compatible) trace id fromAwsOtelTracerProviderConfigurer, disconnected from the invocation's X-Ray trace.This affects only the wrapper layer. The javaagent layer wires X-Ray propagation through bytecode instrumentation and is unaffected.
Fix
Add an
AutoConfigurationCustomizerProvider(registered via SPI, packaged only into the wrapper extension jar) that wraps every configured propagator:extractfirst runs normal propagation from the event carrier (e.g. API Gateway headers). An already-valid remote parent always wins.com.amazonaws.xray.traceHeadersystem property and presents it to the already-configured propagators as a syntheticX-Amzn-Trace-Idheader, delegating parsing to the X-Ray propagator the wrapper layer already configures viaOTEL_PROPAGATORS.The property is re-read on every extraction (the JVM is reused across invocations). No new runtime dependency is introduced — the X-Ray propagator is already supplied and configured by the wrapper layer. If
OTEL_PROPAGATORSexcludes xray, the property is ignored.Files changed
java/src/main/java/software/amazon/opentelemetry/lambda/AwsLambdaXrayContextAutoConfigurationCustomizerProvider.java— new customizer + wrapping propagatorjava/src/main/resources/META-INF/services/io.opentelemetry.sdk.autoconfigure.spi.AutoConfigurationCustomizerProvider— SPI registrationjava/build.gradle.kts— test deps +useJUnitPlatform(); extracted version constantsTesting
validate trace samplepasses forjava-wrapperon both amd64 and arm64 (run 30672918038; a fresh full soak run is in progress to confirm on a clean matrix).Notes for reviewers
fix/nodejs-soak-otel-v0.151.0), since it builds on the collectorTelemetryfactory fix that the soak environment requires. Please merge fix(soak): repair OTel v0.151.0 soak failures (collector Telemetry factory, go/nodejs trace validation, Go CI) #1138 first (or retarget this tomainafter fix(soak): repair OTel v0.151.0 soak failures (collector Telemetry factory, go/nodejs trace validation, Go CI) #1138 merges).🤖 This change was prepared with AI assistance and reviewed by the submitter.