Skip to content

fix(aws-lambda): Remove messaging.batch.message_count from the Lambda span - #8219

Draft
sentry-junior[bot] wants to merge 3 commits into
major/3.0from
junior/aws-lambda-messaging-batch-count
Draft

sentry-junior[bot] wants to merge 3 commits into
major/3.0from
junior/aws-lambda-messaging-batch-count

Conversation

@sentry-junior

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

Copy link
Copy Markdown
Contributor

Description

The Lambda span set messaging.batch.message_count to 1 for every event that isn't a list, and to len(event) for a top-level list. An SQS or SNS delivery is a dict with Records, so a batch of 10 messages reported 1. HTTP calls and direct invocations reported a batch they don't have.

This PR removes the attribute from the Lambda span. The count belongs on messaging spans, as in the OTel messaging conventions:

The JS SDK doesn't set it on the Lambda span either. The attribute was added in 3.0 (#7941) and never shipped in 2.x, so no released behavior changes.

The first version of this PR counted SQS/SNS records instead. This version is smaller, and it removes the overlap with #8222.

Note for review: this is narrower than PY-3015, which asks to keep the attribute for SQS/SNS deliveries. @alexander-alderman-webb, please confirm that's OK.

Issues

  • resolves: PY-3015

via @dingsdax.

--

View Session [Sentry]

…NS batches

The Lambda span set messaging.batch.message_count to 1 for every non-list
event and to len(event) for a top-level list. An SQS or SNS delivery is a
dict with Records, so a batch of 10 messages reported 1, and HTTP or
direct invocations reported a batch they don't have.

Set it only when all records come from SQS or SNS, to the number of
records.

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-3015

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Coverage Results 📊

✅ 57860 passed | ⏭️ 3008 skipped | Total: 60868 | Pass Rate: 95.06% | Execution Time: 157m 36s

📊 Comparison with Base Branch

Metric Change
Total Tests 📉 -83809
Passed Tests 📉 -79361
Failed Tests —
Skipped Tests 📉 -4448

All tests are passing successfully.

❌ Patch coverage is 13.33% (2 of 15 changed executable lines covered; target 80%).
Project statement coverage is 90.34% (up 0.03 percentage points from base (df16ce5) to head (46ed68d)).

Changed files with executable lines (1)
File Patch coverage Changed executable lines
sentry_sdk/integrations/aws_lambda/_handler.py 13.33% 2/15 covered; missed: 47, 48, 50, 51, 52, 54, 60, 61, 63, 189, 190, 191, 192
Coverage diff
@@            Coverage Diff             @@
##        master     #8219       +/-##
==========================================
+ Coverage    90.31%    90.34%    +0.03%
==========================================
  Files          203       199        -4
  Tracked lines     26933     21316     -5617
  Branches     10058      7374     -2684
==========================================
- Hits         24321     19256     -5065
+ Misses        2612      2060      -552
+ Partials      1518      1233      -285

Generated by Coverage Action

… span

Replace the SQS/SNS record counting with a plain removal. The count
belongs on messaging spans (boto3 receive and batch-send spans, and the
queue.process span for SQS/SNS triggers), as in the OTel messaging
conventions. The JS SDK doesn't set it on the Lambda span either.

The attribute was added in 3.0 and never shipped in 2.x.

Co-Authored-By: johdax <114897+dingsdax@users.noreply.github.com>
@sentry-junior sentry-junior Bot changed the title fix(aws-lambda): Only set messaging.batch.message_count for SQS and SNS batches fix(aws-lambda): Remove messaging.batch.message_count from the Lambda span Nov 9, 2026
sentry-junior Bot added a commit that referenced this pull request Nov 9, 2026
…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>

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