Skip to content

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

Open
sentry-junior[bot] wants to merge 9 commits into
major/3.0from
junior/aws-lambda-invoke-trace-continuation
Open

sentry-junior[bot] wants to merge 9 commits into
major/3.0from
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 (merged), 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. The one change: client_context and custom are read with getattr, so a context object without them falls back to event headers instead of failing. It's the first of three stacked PRs for the stretch Lambda work: this PR → trigger detection (#8222) → queue.process spans (#8223).

Issues

via @dingsdax.

--

View Session [Sentry]

pabloDeputter and others added 6 commits October 23, 2026 15:08
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 📊

✅ 58794 passed | ⏭️ 3071 skipped | Total: 61865 | Pass Rate: 95.04% | Execution Time: 155m 19s

📊 Comparison with Base Branch

Metric Change
Total Tests 📉 -85010
Passed Tests 📉 -80316
Failed Tests —
Skipped Tests 📉 -4694

All tests are passing successfully.

❌ Patch coverage is 16.67% (1 of 6 changed executable lines covered; target 80%).
Project statement coverage is 90.43% (up 0.19 percentage points from base (8abf619) to head (1b7058c)).

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.24%    90.43%    +0.19%
==========================================
  Files          203       199        -4
  Tracked lines     27125     21790     -5335
  Branches     10142      7584     -2558
==========================================
- Hits         24478     19704     -4774
+ Misses        2647      2086      -561
+ Partials      1541      1255      -286

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>
Base automatically changed from pablo/boto3-add-lambda-extension to major/3.0 November 11, 2026 09:39
…a-invoke-trace-continuation

# Conflicts:
#	sentry_sdk/integrations/boto3/_client.py
#	sentry_sdk/integrations/boto3/_instrumentation.py
#	sentry_sdk/integrations/boto3/_services/base.py
#	sentry_sdk/integrations/boto3/_services/lambda_.py
#	sentry_sdk/integrations/boto3/_services/registry.py
@sentry-junior
sentry-junior Bot marked this pull request as ready for review November 11, 2026 12:43
@sentry-junior
sentry-junior Bot requested a review from a team as a code owner November 11, 2026 12:43

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.

2 participants