Repository navigation
feat(boto3): Add SQS/SNS trace propagation - #8145
pabloDeputter wants to merge 23 commits into
Conversation
Coverage Results 📊✅ 58328 passed | ❌ 2 failed | ⏭️ 3070 skipped | Total: 61400 | Pass Rate: 95% | Execution Time: 161m 10s 📊 Comparison with Base Branch
➕ New Tests (2)View new tests
❌ Failed Tests
|
| File | Patch coverage | Changed executable lines |
|---|---|---|
| sentry_sdk/integrations/boto3/_utils.py | 92.86% | 26/28 covered; missed: 114, 115; partial branches: 111, 113 |
| sentry_sdk/integrations/boto3/_services/sqs.py | 94.74% | 36/38 covered; missed: 53, 54 |
| sentry_sdk/consts.py | 100.00% | 2/2 covered |
| sentry_sdk/integrations/boto3/_services/sns.py | 100.00% | 4/4 covered |
Coverage diff
@@ Coverage Diff @@
## master #8145 +/-##
==========================================
+ Coverage 90.24% 90.41% +0.17%
==========================================
Files 203 199 -4
Tracked lines 27125 21784 -5341
Branches 10142 7582 -2560
==========================================
- Hits 24478 19695 -4783
+ Misses 2647 2089 -558
+ Partials 1541 1255 -286Generated by Coverage Action
- stop reading operation type from attributes in `get_span_name()` so that failure in `get_request_attributes()` can't make this fail as well - wrap URL parsing in `get_request_attributes()` so failure just loses the attributes that come from url
…sqs-extension Co-Authored-By: Johannes Daxböck <114897+dingsdax@users.noreply.github.com>
…-extension Co-Authored-By: Johannes Daxböck <114897+dingsdax@users.noreply.github.com>
Co-Authored-By: Johannes Daxböck <114897+dingsdax@users.noreply.github.com> # Conflicts: # sentry_sdk/integrations/boto3/_services/sqs.py
Send a message, receive what was injected, and check that the receive span links to the send span. Covers SQS and an SNS notification delivered to SQS without raw message delivery. Co-Authored-By: johdax <114897+dingsdax@users.noreply.github.com>
Botocore validates params after our hook, so a bad Entries or ARN value now only loses that attribute, not every SQS request attribute. Move the batch error.type code to _utils so SNS can share it, and link the SQS docs for BatchResultErrorEntry. Co-Authored-By: Johannes Daxböck <114897+dingsdax@users.noreply.github.com>
…-extension Co-Authored-By: Johannes Daxböck <114897+dingsdax@users.noreply.github.com>
Co-Authored-By: Johannes Daxböck <114897+dingsdax@users.noreply.github.com>
…/sns-propagation Co-Authored-By: Johannes Daxböck <114897+dingsdax@users.noreply.github.com> # Conflicts: # sentry_sdk/integrations/boto3/_services/sns.py # sentry_sdk/integrations/boto3/_services/sqs.py # sentry_sdk/integrations/boto3/_utils.py
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 7d93a71. Configure here.
Co-Authored-By: Ivana Kellyer <131587164+sentrivana@users.noreply.github.com>
### Description Adds `Boto3Integration(propagate_traces=True)`. Setting it to `False` stops the integration from changing the request params of AWS calls: - Lambda `Invoke` no longer gets trace data in `ClientContext`. - Once #8145 lands: SQS `SendMessage` / `SendMessageBatch` and SNS `Publish` / `PublishBatch` no longer get `sentry-trace` / `baggage` message attributes, and SQS `ReceiveMessage` no longer appends our names to `MessageAttributeNames`. The option gates the shared `get_request_params` hook, so it covers every extension that uses it without per-service changes. Spans are still created as before. This is an escape hatch for setups where the added data breaks calls, e.g. a queue or topic whose `MaximumMessageSize` is set below the 256 KiB the #8145 size check assumes, or consumers that reject unknown attributes. The name matches `CeleryIntegration(propagate_traces=...)`. HTTP `sentry-trace` / `baggage` headers on AWS requests are not affected. They're also added by the stdlib integration and are already controlled by `trace_propagation_targets`. Independent of #8145. The SQS/SNS test cases pass trivially until #8145 is merged, and guard the option after that. Whichever PR merges second needs a small conflict fix at the end of `test_trace_propagation.py`, since both append tests there. <!-- junior-request-attribution:start --> via @sentrivana. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:slack%3AC0BTREZTS2Z%3A1794401901.814229 --> -- [View Session](https://junior-prod.sentry.dev/conversations/slack%3AC0BTREZTS2Z%3A1794401901.814229) [[Sentry]](https://sentry.sentry.io/explore/conversations/slack%3AC0BTREZTS2Z%3A1794401901.814229/?project=4510944073809921) <!-- junior-session-footer:end --> --------- Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: Ivana Kellyer <131587164+sentrivana@users.noreply.github.com> Co-authored-by: Ivana Kellyer <ivana.kellyer@sentry.io>
…sqs/sns-propagation Co-Authored-By: Ivana Kellyer <131587164+sentrivana@users.noreply.github.com> # Conflicts: # tests/integrations/boto3/test_trace_propagation.py

Description
Propagates the trace through SQS and SNS messages, so the consumer can be linked back to the request that sent the message.
Send side (
SendMessage,SendMessageBatch,Publish,PublishBatch):sentry-traceandbaggageasStringmessage attributes, on the message or on each batch entry.trace_propagation_targetsmatch the endpoint.Receive side (
ReceiveMessage):sentry-traceandbaggagetoMessageAttributeNames, so SQS returns them. Only when the span is recorded, and not when the caller already asks forAllor.*.sentry.link.type: message_origin.Tests: injection and extraction for single and batch calls, the limits above, and a round-trip test: send a message, receive what was injected, and check that the link points at the send span.
Stacked on #8142 (SNS), which is stacked on #8137 (SQS).
Issues
via @dingsdax.
--
View Session [Sentry]