You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(lambda): align Python context propagation with JS implementation (#727)
Closes#663
## Summary
- **Problem:** `custom_event_context_extractor` in `otel_wrapper.py`
always used the X-Ray env var (`_X_AMZN_TRACE_ID`) as parent context
because it is always set and valid when active tracing is enabled,
causing upstream W3C trace context (`traceparent`) from event headers to
be ignored and breaking trace continuity.
- **Fix:** Align with the [JS
implementation](https://github.com/aws-observability/aws-otel-js-instrumentation/blob/main/aws-distro-opentelemetry-node-autoinstrumentation/src/patches/instrumentation-patch.ts#L100-L123)
— inject the X-Ray env var into the event headers (replacing any
existing X-Ray header, case-insensitive), then delegate to the global
composite propagator via `get_global_textmap().extract()`. This respects
the propagator priority ordering configured in `otel-instrument`
(`baggage,xray,tracecontext`), where `tracecontext` (W3C) takes
precedence over `xray` when both are present.
- **Tests updated:** Existing tests adapted to explicitly set the global
textmap propagator. Two new tests added:
- `test_xray_ignored_when_propagator_does_not_include_xray` — X-Ray
active tracing on, but only `tracecontext` propagator configured; W3C
headers should be used.
- `test_w3c_takes_precedence_over_xray_when_both_present` — both X-Ray
and W3C headers present with composite propagator; W3C should win.
## Test plan
- [x] All 4 unit tests pass locally (`pytest -v`)
- [x] Coverage: `otel_wrapper.py` at 90% (uncovered lines are
error-handling edge cases)
- [x] Lint passes: `black`, `isort`, `flake8` all clean
Copy file name to clipboardExpand all lines: CHANGELOG.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,6 +12,8 @@ If your change does not need a CHANGELOG entry, add the "skip changelog" label t
12
12
13
13
## Unreleased
14
14
15
+
- fix(lambda-layer): align context propagation with JS — delegate to global propagator so W3C traceparent is no longer ignored when X-Ray active tracing is enabled
0 commit comments