Skip to content

feat(aws-lambda): Continue the trace from Invoke ClientContext - #8221

Draft
sentry-junior[bot] wants to merge 1 commit into
pablo/boto3-add-lambda-extensionfrom
junior/aws-lambda-invoke-trace-continuation
Draft

sentry-junior[bot] wants to merge 1 commit into
pablo/boto3-add-lambda-extensionfrom
junior/aws-lambda-invoke-trace-continuation

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Description

With #8117, a synchronous boto3 Invoke carries sentry-trace and baggage in ClientContext.custom. This PR adds the receiving side: the Lambda integration continues the trace from context.client_context.custom. ClientContext wins over event headers, because a forwarded HTTP event can still carry headers from further upstream.

sam local drops ClientContext, so the new ClientContextTrace test function hands the event's client_context to the runtime. That way the container tests can cover it.

This is Pablo's code from pablo/aws-lambda-client-context-trace, squashed into one commit with no other changes. It's the first of three stacked drafts for the stretch Lambda work: this PR → trigger detection → queue.process spans. It's a draft so CI can run the Lambda container tests on it for the first time.

Issues

via @dingsdax.

--

View Session [Sentry]

A synchronous boto3 Invoke now carries sentry-trace and baggage in
ClientContext.custom (added with the Lambda service extension). The
Lambda integration continues the trace from there. ClientContext wins
over event headers, because a forwarded HTTP event can keep headers
from further upstream.

The ClientContextTrace test function works around sam local, which
drops ClientContext, by handing the event's client_context to the
runtime.

Co-Authored-By: Johannes Daxböck <114897+dingsdax@users.noreply.github.com>
@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Coverage Results 📊

✅ 57651 passed | ⏭️ 2979 skipped | Total: 60630 | Pass Rate: 95.09% | Execution Time: 157m 33s

📊 Comparison with Base Branch

Metric Change
Total Tests 📉 -84047
Passed Tests 📉 -79570
Failed Tests —
Skipped Tests 📉 -4477

All tests are passing successfully.

❌ Patch coverage is 20.00% (1 of 5 changed executable lines covered; target 80%).
Project statement coverage is 90.19% (down 0.11 percentage points from base (7ff8eb7) to head (7ea5204)).

Changed files with executable lines (1)
File Patch coverage Changed executable lines
sentry_sdk/integrations/aws_lambda/_handler.py 20.00% 1/5 covered; missed: 193, 194, 199, 201
Coverage diff
@@            Coverage Diff             @@
##        master     #8221       +/-##
==========================================
- Coverage    90.30%    90.19%    -0.11%
==========================================
  Files          203       198        -5
  Tracked lines     26933     21392     -5541
  Branches     10058      7404     -2654
==========================================
- Hits         24321     19293     -5028
+ Misses        2612      2099      -513
+ Partials      1518      1239      -279

Generated by Coverage Action

@linear-code

linear-code Bot commented Nov 9, 2026

Copy link
Copy Markdown

PY-3009

This branch has not been deployed

No deployments
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.

1 participant