Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion sentry_sdk/integrations/huey.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
9 changes: 8 additions & 1 deletion tests/integrations/huey/test_huey.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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"
Expand Down
3 changes: 0 additions & 3 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading