fix(java-wrapper): link wrapper spans to invocation X-Ray trace - #1140
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.
alexperez52
approved these changes
Aug 3, 2026
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
Links the AWS SDK wrapper's spans to the invocation's X-Ray trace on managed Java 17+ Lambda runtimes.
On these runtimes the per-invocation X-Ray trace context is exposed via the
com.amazonaws.xray.traceHeadersystem property rather than the_X_AMZN_TRACE_IDenvironment variable that the OTel Lambda wrapper reads. As a result the SDK wrapper's spans were assigned a fresh X-Ray-compatible trace id (fromAwsOtelTracerProviderConfigurer) 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.This adds an
AutoConfigurationCustomizerProviderthat wraps the configured propagators: event-carrier extraction still takes precedence, but when it yields no valid parent the wrapper falls back to thetraceHeadersystem property and presents it to the already-configured X-Ray propagator as a syntheticX-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.Context
This is a re-land of #1139 onto
main. #1139 was merged into the stalefix/nodejs-soak-otel-v0.151.0branch (the pre-squash #1138 branch) rather thanmain, so the fix never reachedmainafter #1138 was squash-merged. This PR cherry-picks the single java-wrapper commit cleanly onto currentmain.Testing
main(4 files, no conflicts)../gradlew build— compile,spotlessCheck, and unit tests pass (AwsLambdaXrayContextAutoConfigurationCustomizerProviderTest: 7/7).