Skip to content

fix(java-wrapper): link wrapper spans to invocation X-Ray trace - #1140

Merged
priyankaDhingra merged 1 commit into
mainfrom
fix/java-wrapper-xray-traceheader-on-main
Aug 3, 2026
Merged

fix(java-wrapper): link wrapper spans to invocation X-Ray trace#1140
priyankaDhingra merged 1 commit into
mainfrom
fix/java-wrapper-xray-traceheader-on-main

Conversation

@priyankaDhingra

Copy link
Copy Markdown
Contributor

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.traceHeader system property rather than the _X_AMZN_TRACE_ID environment variable that 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.

This adds 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.

Context

This is a re-land of #1139 onto main. #1139 was merged into the stale fix/nodejs-soak-otel-v0.151.0 branch (the pre-squash #1138 branch) rather than main, so the fix never reached main after #1138 was squash-merged. This PR cherry-picks the single java-wrapper commit cleanly onto current main.

Testing

  • Cherry-picked cleanly onto main (4 files, no conflicts).
  • ./gradlew build — compile, spotlessCheck, and unit tests pass (AwsLambdaXrayContextAutoConfigurationCustomizerProviderTest: 7/7).
  • Full soak validation on all 5 layers (incl. java-wrapper, both arches) was green on the stacked branch (run 30768913929). Soak must be re-run against this PR branch before merge.

…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
priyankaDhingra requested a review from a team as a code owner August 3, 2026 16:26
@priyankaDhingra
priyankaDhingra merged commit a1655eb into main Aug 3, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants