From df6907b0ad198b00b0a94f1e64fa2d10aebeebc3 Mon Sep 17 00:00:00 2001 From: Alexander Alderman Webb Date: Wed, 8 Jul 2026 11:46:51 +0200 Subject: [PATCH] feat(huey): Add messaging.destination.name attribute to consumer spans --- sentry_sdk/integrations/huey.py | 4 +++- tests/integrations/huey/test_huey.py | 9 ++++++++- uv.lock | 3 --- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/sentry_sdk/integrations/huey.py b/sentry_sdk/integrations/huey.py index c3bbc8abcf..a477266459 100644 --- a/sentry_sdk/integrations/huey.py +++ b/sentry_sdk/integrations/huey.py @@ -4,7 +4,7 @@ import sentry_sdk from sentry_sdk.api import continue_trace, get_baggage, get_traceparent -from sentry_sdk.consts import OP, SPANSTATUS +from sentry_sdk.consts import OP, SPANDATA, SPANSTATUS from sentry_sdk.integrations import DidNotEnable, Integration from sentry_sdk.scope import should_send_default_pii from sentry_sdk.traces import SegmentSource, SpanStatus, StreamedSpan @@ -211,6 +211,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) @@ -228,6 +229,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 8cca10d54a..dec139b08b 100644 --- a/tests/integrations/huey/test_huey.py +++ b/tests/integrations/huey/test_huey.py @@ -7,7 +7,7 @@ import sentry_sdk from sentry_sdk import start_transaction -from sentry_sdk.consts import OP +from sentry_sdk.consts import OP, SPANDATA from sentry_sdk.integrations.huey import HueyIntegration from sentry_sdk.traces import SegmentSource, SpanStatus from sentry_sdk.utils import parse_version @@ -99,6 +99,9 @@ def division(a, b): assert enqueue_span["attributes"]["sentry.op"] == OP.QUEUE_SUBMIT_HUEY 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 @@ -118,6 +121,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" diff --git a/uv.lock b/uv.lock index 855c128ef8..fb1818bba8 100644 --- a/uv.lock +++ b/uv.lock @@ -6,9 +6,6 @@ resolution-markers = [ "python_full_version < '3.15'", ] -[options] -prerelease-mode = "allow" - [manifest] [manifest.dependency-groups]