diff --git a/sentry_sdk/integrations/huey.py b/sentry_sdk/integrations/huey.py index 4023a7b56c..a1c9d6a357 100644 --- a/sentry_sdk/integrations/huey.py +++ b/sentry_sdk/integrations/huey.py @@ -213,6 +213,7 @@ def _sentry_execute( "sentry.op": OP.QUEUE_TASK_HUEY, "sentry.origin": HueyIntegration.origin, "sentry.span.source": SegmentSource.TASK, + SPANDATA.MESSAGING_DESTINATION_NAME: self.name, "messaging.message.id": task.id, "messaging.message.system": "huey", "messaging.message.retry.count": (task.default_retries or 0) @@ -230,6 +231,7 @@ def _sentry_execute( ) transaction.set_status(SPANSTATUS.OK) span_ctx = sentry_sdk.start_transaction(transaction) + span_ctx.set_data(SPANDATA.MESSAGING_DESTINATION_NAME, self.name) if not getattr(task, "_sentry_is_patched", False): task.execute = _wrap_task_execute(task.execute) diff --git a/tests/integrations/huey/test_huey.py b/tests/integrations/huey/test_huey.py index be9bc4458a..bfd04791dd 100644 --- a/tests/integrations/huey/test_huey.py +++ b/tests/integrations/huey/test_huey.py @@ -102,6 +102,9 @@ def division(a, b): ) assert execute_span["is_segment"] assert execute_span["attributes"]["sentry.op"] == OP.QUEUE_TASK_HUEY + assert ( + execute_span["attributes"][SPANDATA.MESSAGING_DESTINATION_NAME] == huey.name + ) assert execute_span["name"] == "division" assert execute_span["status"] == ( SpanStatus.ERROR if task_fails else SpanStatus.OK @@ -121,6 +124,10 @@ def division(a, b): assert event["type"] == "transaction" assert event["transaction"] == "division" assert event["transaction_info"] == {"source": "task"} + assert ( + event["contexts"]["trace"]["data"][SPANDATA.MESSAGING_DESTINATION_NAME] + == huey.name + ) if task_fails: assert event["contexts"]["trace"]["status"] == "internal_error"