Skip to content

feat(aws-lambda): Add queue.process spans for messaging triggers - #8223

Draft
sentry-junior[bot] wants to merge 3 commits into
junior/aws-lambda-triggerfrom
junior/aws-lambda-queue-process
Draft

sentry-junior[bot] wants to merge 3 commits into
junior/aws-lambda-triggerfrom
junior/aws-lambda-queue-process

Conversation

@sentry-junior

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

Copy link
Copy Markdown
Contributor

Description

For an SQS or SNS delivery, the handler now runs inside a queue.process child span of kind consumer. The span has:

  • messaging.system
  • messaging.operation.type and messaging.operation.name, both process
  • the batch message count
  • the destination name (queue or topic, from the first record)

The span links to each distinct producer context in the records' Sentry message attributes: SQS messageAttributes, SNS MessageAttributes, and SQS bodies that wrap an SNS notification. This gives an SQS-triggered Lambda a link back to the request that sent the message. It also fills in the processing side of the Queues insight.

This is Pablo's code from pablo/aws-lambda-messaging, moved directly onto trigger detection (#8222). On his branch it sat on top of HTTP and invocation attribute work (PY-3017, PY-3019, PY-3021), which isn't part of the November plan. Moving it needed one hand-made change: in _handler.py I kept the base handler and only wrapped the handler call in the process span, because Pablo's version of that block includes the HTTP status and error.type code from the dropped commits. _trigger.py and the new process-span tests match his branch exactly. The only tests left out are the ones for the dropped attributes.

test_process_span_error covers a handler that raises.

Open points for review:

  • messaging.message.id on single-message process spans isn't added yet (proposed in PY-3020).
  • MESSAGING_OPERATION_TYPE and MESSAGING_OPERATION_NAME are also added in feat(boto3): Add SQS extension  #8137, so consts.py will conflict when both land.

Third of three stacked drafts (#8221 → #8222 → this).

Issues

via @dingsdax.

--

View Session [Sentry]

For an SQS, SNS, Kafka, ActiveMQ or RabbitMQ delivery, the handler runs
inside a queue.process child span (kind consumer) with messaging.system,
messaging.operation.type and messaging.operation.name set to process,
the batch message count, and the destination name when all records
share it.

The span links to each distinct producer context found in the records'
Sentry message attributes: SQS messageAttributes, SNS MessageAttributes,
and SQS bodies that wrap an SNS notification.

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

@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Coverage Results 📊

✅ 57743 passed | ⏭️ 2979 skipped | Total: 60722 | Pass Rate: 95.09% | Execution Time: 154m 34s

📊 Comparison with Base Branch

Metric Change
Total Tests 📉 -83955
Passed Tests 📉 -79478
Failed Tests —
Skipped Tests 📉 -4477

All tests are passing successfully.

❌ Patch coverage is 30.16% (19 of 63 changed executable lines covered; target 80%).
Project statement coverage is 89.92% (down 0.38 percentage points from base (f864c51) to head (5a479b9)).

Changed files with executable lines (3)
File Patch coverage Changed executable lines
sentry_sdk/integrations/aws_lambda/_trigger.py 25.00% 13/52 covered; missed: 113, 114, 117, 120, 121, 122, 127, 128, 129, 132, 134, 139, 140, 141, 142, 143, 144, 145, 147, 148, 149, 150, 151, 153, 154, 155, 156, 157, 158, 160, 165, 166, 167, 169, 170, 171, 174, 179, 181
sentry_sdk/integrations/aws_lambda/_handler.py 28.57% 2/7 covered; missed: 214, 215, 216, 217, 218
sentry_sdk/consts.py 100.00% 4/4 covered
Coverage diff
@@            Coverage Diff             @@
##        master     #8223       +/-##
==========================================
- Coverage    90.30%    89.92%    -0.38%
==========================================
  Files          203       199        -4
  Tracked lines     26933     21485     -5448
  Branches     10058      7442     -2616
==========================================
- Hits         24321     19320     -5001
+ Misses        2612      2165      -447
+ Partials      1518      1239      -279

Generated by Coverage Action

sentry-junior Bot and others added 2 commits November 9, 2026 07:59
…-process

Co-Authored-By: johdax <114897+dingsdax@users.noreply.github.com>

# Conflicts:
#	sentry_sdk/integrations/aws_lambda/_handler.py
#	sentry_sdk/integrations/aws_lambda/_trigger.py
The error is captured, both the process span and the invocation span
are marked as errors, and the exception still reaches the Lambda
runtime.

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