GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(aws-lambda): Continue the trace from Invoke ClientContext by sentry-junior[bot] · Pull Request #8221 · getsentry/sentry-python

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 9, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

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

  • resolves: PY-3009 (receiving side; feat(boto3): Add Lambda extension #8117 does the injection)
  • Part of feat(boto3): Add trace propagation through Lambda Invoke #8071

via @dingsdax.

--

View Session [Sentry]

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
pabloDeputter and others added 6 commits October 23, 2026 15:08
@pabloDeputter
wip
30d436a
@pabloDeputter
fix wrong parent ID
d5767c4
@pabloDeputter
wip
ae57d8b
@pabloDeputter
Merge branch 'major/3.0' into pablo/boto3-add-lambda-extension
0266db9
@pabloDeputter
Merge branch 'major/3.0' into pablo/boto3-add-lambda-extension
7ff8eb7
@sentry-junior @dingsdax
feat(aws-lambda): Continue the trace from Invoke ClientContext
7ea5204
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 <[email protected]>
@sentry-junior sentry-junior Bot assigned dingsdax Nov 9, 2026
This was referenced Nov 9, 2026
feat(aws-lambda): Detect Lambda triggers #8222
Merged
feat(aws-lambda): Add queue.process spans for messaging triggers #8223
Merged
@github-actions

github-actions Bot commented Nov 9, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

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

sentry-junior[bot] reacted with eyes emoji
All reactions
  • 👀 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@linear-code

linear-code Bot commented Nov 9, 2026

Copy link
Copy Markdown

PY-3009

sentry-junior[bot] reacted with eyes emoji
All reactions
  • 👀 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@sentry-junior @dingsdax
fix(aws-lambda): Don't assume the context has client_context
120a441
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 <[email protected]>
Base automatically changed from pablo/boto3-add-lambda-extension to major/3.0 November 11, 2026 09:39
@sentry-junior
Merge remote-tracking branch 'origin/major/3.0' into junior/aws-lambd…
e58c212
…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
@sentry-junior
Merge remote-tracking branch 'origin/major/3.0' into junior/aws-lambd…
1b7058c
…a-invoke-trace-continuation
@sentry-junior sentry-junior Bot mentioned this pull request Nov 12, 2026
feat(aws-lambda): Link SQS and SNS invocations to their producers #8257
Merged
sentrivana
sentrivana approved these changes Nov 12, 2026
View reviewed changes
@sentrivana
sentrivana merged commit 45f0192 into major/3.0 Nov 12, 2026
298 of 301 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@sentrivana
sentrivana deleted the junior/aws-lambda-invoke-trace-continuation branch November 12, 2026 11:23
sentrivana added a commit that referenced this pull request Nov 12, 2026
@sentry-junior @alexander-alderman-webb @sentrivana
feat(aws-lambda): Link SQS and SNS invocations to their producers (#8257
3da95c6
)

### Description

Since #8137, #8142, and #8145, boto3 puts `sentry-trace` in SQS and SNS
message attributes, but nothing reads it on the Lambda side. This PR is
the smallest change that closes the loop for SQS- and SNS-triggered
functions. The Lambda integration now reads `sentry-trace` from each
record and adds a `message_origin` link from the invocation span to each
distinct producer span. This matches what the boto3 `ReceiveMessage`
span already does. Messages never become the invocation's parent.

It reads:
- SQS records: `messageAttributes["sentry-trace"].stringValue`
- SNS records: `Sns.MessageAttributes["sentry-trace"].Value`
- SNS → SQS without raw message delivery: the SNS envelope in the SQS
`body`, the same as boto3 does

Links are deduplicated, because a batch send gives many messages the
same producer span, and capped at 128, OTel's default, because Lambda
can deliver up to 10,000 SQS messages at once.

**Scope.** This is intentionally kept separate from the stretch stack.
It doesn't add `faas.trigger` (#8222) or `queue.process` spans (#8223),
and it doesn't touch `messaging.batch.message_count` (#8229). The
invocation span is otherwise unchanged. Synchronous `Invoke` propagation
through `ClientContext` is #8221. That PR changes the `continue_trace`
call and this one only adds `links=`, so the two are independent.

The link-building code repeats boto3's `_message_link` in a Lambda-event
shape: Lambda records use `messageAttributes` / `stringValue` / `body`,
while the boto3 response uses `MessageAttributes` / `StringValue` /
`Body`. Importing from the boto3 integration would make `aws_lambda`
depend on botocore.

**Testing.** `test_producer_links` sends SQS, SNS, and SNS-to-SQS events
to `BasicOkSpanStreaming`. It asserts the segment span's `links` and
that the segment span has no parent. It passes in CI's Cloud (Lambda)
jobs, and `ruff` and `mypy sentry_sdk` pass. `codecov/patch` is red
because the Lambda tests run in `sam local` containers, so their
coverage isn't counted.

#### Issues
* Part of #8081

<!-- junior-request-attribution:start -->
via **webb**, @sentrivana.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:slack%3AC09M26BC6A1%3A1794211222.463239 -->

--

[View
Session](https://junior-prod.sentry.dev/conversations/slack%3AC09M26BC6A1%3A1794211222.463239)
[[Sentry]](https://sentry.sentry.io/explore/conversations/slack%3AC09M26BC6A1%3A1794211222.463239/?project=4510944073809921)

<!-- junior-session-footer:end -->

---------

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: Alexander Webb <[email protected]>
Co-authored-by: Ivana Kellyer <[email protected]>
sentrivana pushed a commit that referenced this pull request Nov 12, 2026
@sentry-junior @pabloDeputter @dingsdax
feat(aws-lambda): Detect Lambda triggers (#8222)
4213a82
### Description

Sets `faas.trigger` on the Lambda span based on the shape of the
delivered event:
- `http`: API Gateway REST/HTTP, function URLs, ALB, CloudFront, AppSync
- `pubsub`: SQS, SNS, Kinesis, Kafka, MQ, SES, EventBridge
- `datasource`: S3, DynamoDB Streams, DocumentDB
- `timer`: EventBridge schedules
- `other`: anything else

The trigger is read from the event envelope, never from its payload.
`test_trigger` has one case per code path. Other event sources use the
same lookup table, so they have no extra cases.

This PR doesn't touch `messaging.batch.message_count`. That change is in
#8229.

This is Pablo's code from `pablo/aws-lambda-trigger`, without his batch
counting for the invocation span. It's the second of three stacked PRs
(#8221 → this → #8223).

#### Issues
* resolves: PY-3018 (`faas.trigger` part; the per-source attributes in
the issue aren't in this PR)
* Part of #8081

<!-- junior-request-attribution:start -->
via @dingsdax.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:slack%3AC0C9X9V5NMT%3A1793904671.980379 -->

--

[View
Session](https://junior-prod.sentry.dev/conversations/slack%3AC0C9X9V5NMT%3A1793904671.980379)
[[Sentry]](https://sentry.sentry.io/explore/conversations/slack%3AC0C9X9V5NMT%3A1793904671.980379/?project=4510944073809921)

<!-- junior-session-footer:end -->

---------

Co-authored-by: Pablo Deputter <[email protected]>
Co-authored-by: Pablo Deputter <[email protected]>
Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: Johannes Daxböck <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@sentrivana sentrivana sentrivana approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@dingsdax dingsdax

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@sentrivana @dingsdax @pabloDeputter
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.