Skip to content

Conversation

majanjua-amzn
Copy link

@majanjua-amzn majanjua-amzn commented Sep 23, 2025

Which problem is this PR solving?

  • AWSXRayPropagator doesn't inject or extract the OTel trace state appropriately, which makes the extracted span context default to an empty trace state.

Short description of the changes

  • Update extract to extract the trace state from the context if available and update the returned context accordingly
  • Updated comments/title of trace state injection test and created new unit test for extraction
  • Updated CHANGELOG

@github-actions github-actions bot requested a review from jj22ee September 23, 2025 18:54
@majanjua-amzn majanjua-amzn marked this pull request as ready for review September 23, 2025 18:55
@majanjua-amzn majanjua-amzn requested a review from a team as a code owner September 23, 2025 18:55
@majanjua-amzn majanjua-amzn force-pushed the main branch 2 times, most recently from a7a68db to d8253d8 Compare September 25, 2025 21:20
@majanjua-amzn majanjua-amzn changed the title fix: ensure aws-xray-propagator propagates trace state fix: ensure aws-xray-propagator maintains trace state Sep 25, 2025

### Bug Fixes

* fix: ensure aws-xray-propagator propagates trace state ([#3092](https://github.com/open-telemetry/opentelemetry-js-contrib/pull/3092))
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the bot is responsible for updating this Changelog, so you'll need to undo this change.

Comment on lines +87 to +94
const finalSpanContext: SpanContext = existingTraceState
? {
...spanContext,
traceState: existingTraceState,
}
: spanContext;

return trace.setSpan(context, trace.wrapSpanContext(finalSpanContext));
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const finalSpanContext: SpanContext = existingTraceState
? {
...spanContext,
traceState: existingTraceState,
}
: spanContext;
return trace.setSpan(context, trace.wrapSpanContext(finalSpanContext));
if (existingTraceState) {
spanContext.traceState = existingTraceState
}
return trace.setSpan(context, trace.wrapSpanContext(spanContext));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants