Skip to content

Prefer Lambda X-Ray trace header from carrier - #3043

Open
akg268 wants to merge 1 commit into
open-telemetry:mainfrom
akg268:codex/aws-lambda-xray-context
Open

Prefer Lambda X-Ray trace header from carrier#3043
akg268 wants to merge 1 commit into
open-telemetry:mainfrom
akg268:codex/aws-lambda-xray-context

Conversation

@akg268

@akg268 akg268 commented Aug 7, 2026

Copy link
Copy Markdown

Summary

  • read com.amazonaws.xray.traceHeader from the extraction carrier before falling back to the system property and _X_AMZN_TRACE_ID
  • keep existing request X-Amzn-Trace-Id extraction behavior so it can still be used as a span link when active tracing provides the parent
  • handle the lowercase carrier key used by the Java instrumentation map getter

Refs 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:spotlessCheck
  • git diff --check

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.traceHeader from 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.

@akg268

akg268 commented Aug 23, 2026

Copy link
Copy Markdown
Author

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.

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