Skip to content

Commit b9899f8

Browse files
feat(huey): Set messaging.destination.name on consumer spans (#6779)
Set `Huey.name` as the `messaging.destination.name` attribute to support span description inference.
1 parent 2dcdd72 commit b9899f8

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

sentry_sdk/integrations/huey.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ def _sentry_execute(
213213
"sentry.op": OP.QUEUE_TASK_HUEY,
214214
"sentry.origin": HueyIntegration.origin,
215215
"sentry.span.source": SegmentSource.TASK,
216+
SPANDATA.MESSAGING_DESTINATION_NAME: self.name,
216217
"messaging.message.id": task.id,
217218
"messaging.message.system": "huey",
218219
"messaging.message.retry.count": (task.default_retries or 0)
@@ -230,6 +231,7 @@ def _sentry_execute(
230231
)
231232
transaction.set_status(SPANSTATUS.OK)
232233
span_ctx = sentry_sdk.start_transaction(transaction)
234+
span_ctx.set_data(SPANDATA.MESSAGING_DESTINATION_NAME, self.name)
233235

234236
if not getattr(task, "_sentry_is_patched", False):
235237
task.execute = _wrap_task_execute(task.execute)

tests/integrations/huey/test_huey.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ def division(a, b):
102102
)
103103
assert execute_span["is_segment"]
104104
assert execute_span["attributes"]["sentry.op"] == OP.QUEUE_TASK_HUEY
105+
assert (
106+
execute_span["attributes"][SPANDATA.MESSAGING_DESTINATION_NAME] == huey.name
107+
)
105108
assert execute_span["name"] == "division"
106109
assert execute_span["status"] == (
107110
SpanStatus.ERROR if task_fails else SpanStatus.OK
@@ -121,6 +124,10 @@ def division(a, b):
121124
assert event["type"] == "transaction"
122125
assert event["transaction"] == "division"
123126
assert event["transaction_info"] == {"source": "task"}
127+
assert (
128+
event["contexts"]["trace"]["data"][SPANDATA.MESSAGING_DESTINATION_NAME]
129+
== huey.name
130+
)
124131

125132
if task_fails:
126133
assert event["contexts"]["trace"]["status"] == "internal_error"

0 commit comments

Comments
 (0)