Skip to content

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

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

sentry-junior[bot] wants to merge 2 commits 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: 153m 18s

📊 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 16.67% (1 of 6 changed executable lines covered; target 80%).
Project statement coverage is 90.18% (down 0.17 percentage points from base (7ff8eb7) to head (120a441)).

Changed files with executable lines (1)
File Patch coverage Changed executable lines
sentry_sdk/integrations/aws_lambda/_handler.py 16.67% 1/6 covered; missed: 193, 194, 195, 196, 198
Coverage diff
@@            Coverage Diff             @@
##        master     #8221       +/-##
==========================================
- Coverage    90.35%    90.18%    -0.17%
==========================================
  Files          203       198        -5
  Tracked lines     26931     21393     -5538
  Branches     10058      7404     -2654
==========================================
- Hits         24331     19292     -5039
+ Misses        2600      2101      -499
+ Partials      1517      1240      -277

Generated by Coverage Action

@linear-code

linear-code Bot commented Nov 9, 2026

Copy link
Copy Markdown

PY-3009

Read client_context and its custom dict with getattr, so a context
object without them falls back to the event headers.

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

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