Prefer Lambda X-Ray trace header from carrier - #3043
Conversation
There was a problem hiding this comment.
Pull request overview
Updates the AWS X-Ray Lambda propagator to prefer the Lambda-specific X-Ray trace header (com.amazonaws.xray.traceHeader) from the extraction carrier (including a lowercase-key variant) before falling back to the system property and _X_AMZN_TRACE_ID, while preserving the existing behavior where the request X-Amzn-Trace-Id can still be extracted for span-linking when an active parent is already present.
Changes:
- Prefer reading
com.amazonaws.xray.traceHeaderfrom the extraction carrier before checking the system property and environment variable. - Add support for the lowercase carrier key (
com.amazonaws.xray.traceheader) to match behavior of certain map-based getters. - Add/extend unit tests to cover precedence, lowercase-key handling, and span-link behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| aws-xray-propagator/src/main/java/io/opentelemetry/contrib/awsxray/propagator/AwsXrayLambdaPropagator.java | Extract Lambda trace header from the carrier first (with lowercase-key fallback) before system/env fallbacks. |
| aws-xray-propagator/src/test/java/io/opentelemetry/contrib/awsxray/propagator/AwsXrayLambdaPropagatorTest.java | Adds tests validating carrier precedence, lowercase key support, and link behavior remains intact. |
|
Gentle ping @srprash @wangzlei when you have a chance. The checks are green and Copilot did not report any comments. This is the contrib-side companion for open-telemetry/opentelemetry-java-instrumentation#19438 to support Lambda X-Ray trace-header priority. |
Summary
com.amazonaws.xray.traceHeaderfrom the extraction carrier before falling back to the system property and_X_AMZN_TRACE_IDX-Amzn-Trace-Idextraction behavior so it can still be used as a span link when active tracing provides the parentRefs open-telemetry/opentelemetry-java-instrumentation#15517
Companion instrumentation PR: open-telemetry/opentelemetry-java-instrumentation#19438
Testing
./gradlew :aws-xray-propagator:test --tests io.opentelemetry.contrib.awsxray.propagator.AwsXrayLambdaPropagatorTest./gradlew :aws-xray-propagator:spotlessCheckgit diff --check