Skip to content

Commit 66dec84

Browse files
feat(huey): Add messaging.destination.name attribute to producer spans
1 parent e2dd162 commit 66dec84

3 files changed

Lines changed: 8 additions & 5 deletions

File tree

sentry_sdk/integrations/huey.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import sentry_sdk
66
from sentry_sdk.api import continue_trace, get_baggage, get_traceparent
7-
from sentry_sdk.consts import OP, SPANSTATUS
7+
from sentry_sdk.consts import OP, SPANDATA, SPANSTATUS
88
from sentry_sdk.integrations import DidNotEnable, Integration
99
from sentry_sdk.scope import should_send_default_pii
1010
from sentry_sdk.traces import SegmentSource, SpanStatus, StreamedSpan
@@ -86,6 +86,7 @@ def _sentry_enqueue(
8686
attributes={
8787
"sentry.op": OP.QUEUE_SUBMIT_HUEY,
8888
"sentry.origin": HueyIntegration.origin,
89+
SPANDATA.MESSAGING_DESTINATION_NAME: self.name,
8990
},
9091
)
9192
else:
@@ -94,6 +95,7 @@ def _sentry_enqueue(
9495
name=span_name,
9596
origin=HueyIntegration.origin,
9697
)
98+
span_ctx.set_data(SPANDATA.MESSAGING_DESTINATION_NAME, self.name)
9799

98100
no_headers_types = (PeriodicTask,) + tuple(
99101
t for t in [HueyGroup, HueyChord] if t is not None

tests/integrations/huey/test_huey.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import sentry_sdk
99
from sentry_sdk import start_transaction
10-
from sentry_sdk.consts import OP
10+
from sentry_sdk.consts import OP, SPANDATA
1111
from sentry_sdk.integrations.huey import HueyIntegration
1212
from sentry_sdk.traces import SegmentSource, SpanStatus
1313
from sentry_sdk.utils import parse_version
@@ -97,6 +97,9 @@ def division(a, b):
9797
enqueue_span, execute_span = payloads
9898

9999
assert enqueue_span["attributes"]["sentry.op"] == OP.QUEUE_SUBMIT_HUEY
100+
assert (
101+
enqueue_span["attributes"][SPANDATA.MESSAGING_DESTINATION_NAME] == huey.name
102+
)
100103
assert execute_span["is_segment"]
101104
assert execute_span["attributes"]["sentry.op"] == OP.QUEUE_TASK_HUEY
102105
assert execute_span["name"] == "division"
@@ -308,6 +311,7 @@ def dummy_task():
308311
assert len(event["spans"])
309312
assert event["spans"][0]["op"] == "queue.submit.huey"
310313
assert event["spans"][0]["description"] == "different_task_name"
314+
assert event["spans"][0]["data"][SPANDATA.MESSAGING_DESTINATION_NAME] == huey.name
311315

312316

313317
def test_huey_propagate_trace(init_huey, capture_events):

uv.lock

Lines changed: 0 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)