refactor(otel): Add X-Ray context extraction with trace ID priority#464
Merged
Merged
Conversation
Introduce extracted trace ID support in DeterministicIdGenerator with priority order: extracted X-Ray > ARN-derived > random. Refactor XRayContextExtractor for robust header parsing and add ExtractedContext record. Wire context extraction into OpenTelemetryDurablePlugin via ContextExtractor interface. Includes unit and integration tests for trace ID priority, X-Ray parsing edge cases, and plugin integration with extracted context.
a0ed2a2 to
edc3887
Compare
SilanHe
reviewed
Jun 17, 2026
| } | ||
| // If no extracted context, idGenerator falls back to ARN-derived trace ID | ||
|
|
||
| // Determine parent context for the invocation span |
Contributor
There was a problem hiding this comment.
is this required? I don't think I'm creating an explicit parentSpan for the invocation span.
Contributor
Author
There was a problem hiding this comment.
I think it will look better visually.
├── Lambda segment (created by AWS automatically)
│
└── durable.invocation
vs
├── Lambda segment (created by AWS automatically)
│
├── durable.invocation
We can remove it later once we have demos ready and if we dont like it
SilanHe
approved these changes
Jun 17, 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.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
Issue Link, if available
#435
Description
Refactors the OTel plugin's trace ID generation to use the X-Ray trace header propagated by the durable execution backend, replacing the external
opentelemetry-aws-xray-propagatordependency with a lightweight hand-rolled parser.The durable execution backend propagates the same
_X_AMZN_TRACE_IDRoot to all invocations of a given execution. By extracting and using this trace ID directly, all spans from all invocations naturally land in a single unified trace without needing ARN-derived hashing. This also enables parent span linkage so invocation spans appear as children of Lambda's X-Ray segment.Demo/Screenshots
N/A
Checklist
Testing
Unit Tests
Have unit tests been written for these changes? Yes
Integration Tests
Have integration tests been written for these changes? Yes, updated
Examples
Has a new example been added for the change? (if applicable) Will add Xray tests in following PR