Skip to content

Conversation

@sam-mosleh
Copy link
Contributor

@sam-mosleh sam-mosleh commented Jan 1, 2026

Description

Automatically inject trace headers in AWS Lambda responses. Fixes #4074

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

  • By checking existence of those headers

Does This PR Require a Core Repo Change?

  • No.

@sam-mosleh sam-mosleh changed the title ✨ Add trace headers to aws_lambda instrumentation feat: Add trace headers to aws_lambda instrumentation Jan 1, 2026
@sam-mosleh sam-mosleh changed the title feat: Add trace headers to aws_lambda instrumentation feat(aws-lambda): Add trace headers to aws_lambda instrumentation Jan 1, 2026
@sam-mosleh sam-mosleh requested a review from a team as a code owner January 1, 2026 20:05
@xrmx xrmx moved this to Ready for review in @xrmx's Python PR digest Jan 13, 2026
@herin049
Copy link
Contributor

herin049 commented Jan 13, 2026

What issue is this trying to solve exactly? Even if you are using API Gateway, Lambda URLs or ALBs, headers should still be propagated normally from client to server. If this change is more about adding the ability to easily retrieve the corresponding trace ID when there is no parent trace to go off of, then there is a tracking issue in the spec for this: open-telemetry/opentelemetry-specification#1355 but from I can tell there is no consensus yet.

If we do decide to implement these changes, I would personally want it to be opt-in only.

@sam-mosleh
Copy link
Contributor Author

@herin049 You’re correct that trace headers are propagated to the Lambda, but the issue occurs on the response path: when using API Gateway v2 or ALB integrations, the generated trace context is not returned to the client, so the client never receives the trace ID and this is particularly problematic when no incoming trace parent exists. I’ve corrected my implementation to use set_global_response_propagator, making the behavior explicitly opt-in for users who require it.

@herin049
Copy link
Contributor

herin049 commented Jan 14, 2026

Ok, I don't really see how this issue is limited to API GW/ALBs though, even if you invoke a lambda function normally with no parent context, you also won't get a reference trace ID back. Either way, approach look OK to me.

@sam-mosleh
Copy link
Contributor Author

@herin049 API Gateway v1 automagically adds the X-Amzn-Trace-Id to the response headers without the need for Lambdas returning it.

@herin049
Copy link
Contributor

Changes LGTM!

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

Labels

None yet

Projects

Status: Ready for review

Development

Successfully merging this pull request may close these issues.

AWS Lambda functions don't inject trace headers in responses

3 participants