Skip to content

Commit df6907b

Browse files
feat(huey): Add messaging.destination.name attribute to consumer spans
1 parent e2dd162 commit df6907b

3 files changed

Lines changed: 11 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
@@ -211,6 +211,7 @@ def _sentry_execute(
211211
"sentry.op": OP.QUEUE_TASK_HUEY,
212212
"sentry.origin": HueyIntegration.origin,
213213
"sentry.span.source": SegmentSource.TASK,
214+
SPANDATA.MESSAGING_DESTINATION_NAME: self.name,
214215
"messaging.message.id": task.id,
215216
"messaging.message.system": "huey",
216217
"messaging.message.retry.count": (task.default_retries or 0)
@@ -228,6 +229,7 @@ def _sentry_execute(
228229
)
229230
transaction.set_status(SPANSTATUS.OK)
230231
span_ctx = sentry_sdk.start_transaction(transaction)
232+
span_ctx.set_data(SPANDATA.MESSAGING_DESTINATION_NAME, self.name)
231233

232234
if not getattr(task, "_sentry_is_patched", False):
233235
task.execute = _wrap_task_execute(task.execute)

tests/integrations/huey/test_huey.py

Lines changed: 8 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
@@ -99,6 +99,9 @@ def division(a, b):
9999
assert enqueue_span["attributes"]["sentry.op"] == OP.QUEUE_SUBMIT_HUEY
100100
assert execute_span["is_segment"]
101101
assert execute_span["attributes"]["sentry.op"] == OP.QUEUE_TASK_HUEY
102+
assert (
103+
execute_span["attributes"][SPANDATA.MESSAGING_DESTINATION_NAME] == huey.name
104+
)
102105
assert execute_span["name"] == "division"
103106
assert execute_span["status"] == (
104107
SpanStatus.ERROR if task_fails else SpanStatus.OK
@@ -118,6 +121,10 @@ def division(a, b):
118121
assert event["type"] == "transaction"
119122
assert event["transaction"] == "division"
120123
assert event["transaction_info"] == {"source": "task"}
124+
assert (
125+
event["contexts"]["trace"]["data"][SPANDATA.MESSAGING_DESTINATION_NAME]
126+
== huey.name
127+
)
121128

122129
if task_fails:
123130
assert event["contexts"]["trace"]["status"] == "internal_error"

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)