Skip to content

refactor(otel): Add X-Ray context extraction with trace ID priority#464

Merged
ayushiahjolia merged 1 commit into
mainfrom
refactor/otel-xray-context-extraction
Jun 17, 2026
Merged

refactor(otel): Add X-Ray context extraction with trace ID priority#464
ayushiahjolia merged 1 commit into
mainfrom
refactor/otel-xray-context-extraction

Conversation

@ayushiahjolia

@ayushiahjolia ayushiahjolia commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

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-propagator dependency with a lightweight hand-rolled parser.

The durable execution backend propagates the same _X_AMZN_TRACE_ID Root 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

  • I have filled out every section of the PR template
  • I have thoroughly tested this change

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

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.
@ayushiahjolia ayushiahjolia force-pushed the refactor/otel-xray-context-extraction branch from a0ed2a2 to edc3887 Compare June 17, 2026 22:18
@ayushiahjolia ayushiahjolia marked this pull request as ready for review June 17, 2026 22:30
@ayushiahjolia ayushiahjolia requested a review from a team June 17, 2026 22:30
}
// If no extracted context, idGenerator falls back to ARN-derived trace ID

// Determine parent context for the invocation span

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.

is this required? I don't think I'm creating an explicit parentSpan for the invocation span.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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

@ayushiahjolia ayushiahjolia merged commit da837f8 into main Jun 17, 2026
12 checks passed
@ayushiahjolia ayushiahjolia deleted the refactor/otel-xray-context-extraction branch June 17, 2026 22:54
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