Skip to content

feat(aws-lambda): Detect Lambda triggers - #8222

Open
sentry-junior[bot] wants to merge 5 commits into
junior/aws-lambda-invoke-trace-continuationfrom
junior/aws-lambda-trigger
Open

sentry-junior[bot] wants to merge 5 commits into
junior/aws-lambda-invoke-trace-continuationfrom
junior/aws-lambda-trigger

Conversation

@sentry-junior

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

Copy link
Copy Markdown
Contributor

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.

messaging.batch.message_count is removed from the Lambda span, the same way as in #8229. The count stays on messaging spans only: boto3 receive and batch-send spans, and queue.process for SQS/SNS triggers (#8223). This repeats #8229's change because this stack is based on #8117, not on #8229. Once #8229 lands, the repeated lines merge cleanly or can be dropped.

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 drafts (#8221 → this → queue.process).

Issues

via @dingsdax.

--

View Session [Sentry]

Classify the delivered event into faas.trigger: http (API Gateway,
function URLs, ALB, CloudFront, AppSync), pubsub (SQS, SNS, Kinesis,
Kafka, MQ, SES, EventBridge), datasource (S3, DynamoDB Streams,
DocumentDB), timer (EventBridge schedules) or other. The trigger is
read from the event envelope, never from its payload.

messaging.batch.message_count is now only set for messaging
deliveries, with the number of delivered messages.

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

linear-code Bot commented Nov 9, 2026

Copy link
Copy Markdown

PY-3018

@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Coverage Results 📊

✅ 58842 passed | ⏭️ 3071 skipped | Total: 61913 | Pass Rate: 95.04% | Execution Time: 152m 51s

📊 Comparison with Base Branch

Metric Change
Total Tests 📉 -84962
Passed Tests 📉 -80268
Failed Tests —
Skipped Tests 📉 -4694

All tests are passing successfully.

❌ Patch coverage is 26.47% (9 of 34 changed executable lines covered; target 80%).
Project statement coverage is 90.34% (up 0.09 percentage points from base (1b7058c) to head (380eec4)).

Changed files with executable lines (3)
File Patch coverage Changed executable lines
sentry_sdk/integrations/aws_lambda/_trigger.py 20.69% 6/29 covered; missed: 40, 45, 54, 56, 57, 58, 60, 61, 65, 66, 69, 71, 72, 74, 75, 77, 78, 79, 81, 82, 86, 87, 89
sentry_sdk/integrations/aws_lambda/_handler.py 33.33% 1/3 covered; missed: 166, 167
sentry_sdk/consts.py 100.00% 2/2 covered
Coverage diff
@@            Coverage Diff             @@
##        master     #8222       +/-##
==========================================
+ Coverage    90.25%    90.34%    +0.09%
==========================================
  Files          203       200        -3
  Tracked lines     27125     21822     -5303
  Branches     10142      7602     -2540
==========================================
- Hits         24478     19713     -4765
+ Misses        2647      2109      -538
+ Partials      1541      1255      -286

Generated by Coverage Action

sentry-junior Bot and others added 3 commits November 9, 2026 07:57
…a span

Keep the count on messaging spans only (boto3 receive and batch-send
spans, and queue.process for SQS/SNS triggers), as in the OTel
messaging conventions and the JS SDK. This drops the batch counting for
Kafka, MQ and RabbitMQ deliveries, and matches #8219 so both PRs change
these lines the same way.

Co-Authored-By: johdax <114897+dingsdax@users.noreply.github.com>
…r/aws-lambda-trigger

Co-Authored-By: Johannes Daxböck <114897+dingsdax@users.noreply.github.com>
Each case is a SAM invoke. The removed cases only checked other keys of
the same lookup table.

Co-Authored-By: Johannes Daxböck <114897+dingsdax@users.noreply.github.com>
@sentry-junior
sentry-junior Bot marked this pull request as ready for review November 11, 2026 17:47
@sentry-junior
sentry-junior Bot requested a review from a team as a code owner November 11, 2026 17:47

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 380eec4. Configure here.

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