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
6 changes: 5 additions & 1 deletion sentry_sdk/integrations/dramatiq.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,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.integrations._wsgi_common import request_body_within_bounds
from sentry_sdk.traces import SegmentSource
Expand Down Expand Up @@ -140,6 +140,7 @@ def before_process_message(self, broker: "Broker", message: "Message[R]") -> Non
"sentry.op": OP.QUEUE_TASK_DRAMATIQ,
"sentry.origin": DramatiqIntegration.origin,
"sentry.span.source": SegmentSource.TASK.value,
SPANDATA.MESSAGING_DESTINATION_NAME: message.queue_name,
},
parent_span=None,
)
Expand All @@ -160,6 +161,9 @@ def before_process_message(self, broker: "Broker", message: "Message[R]") -> Non
source=TransactionSource.TASK,
)
transaction.__enter__()
transaction.set_data(
SPANDATA.MESSAGING_DESTINATION_NAME, message.queue_name
)
message._sentry_span_ctx = transaction

def after_process_message(
Expand Down
10 changes: 9 additions & 1 deletion tests/integrations/dramatiq/test_dramatiq.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 SPANSTATUS
from sentry_sdk.consts import SPANDATA, SPANSTATUS
from sentry_sdk.integrations.dramatiq import DramatiqIntegration
from sentry_sdk.integrations.logging import ignore_logger
from sentry_sdk.tracing import Transaction, TransactionSource
Expand Down Expand Up @@ -172,6 +172,10 @@ def dummy_actor(x, y):
assert segment["is_segment"] is True
assert segment["attributes"]["sentry.op"] == "queue.task.dramatiq"
assert segment["attributes"]["sentry.span.source"] == "task"
assert (
segment["attributes"][SPANDATA.MESSAGING_DESTINATION_NAME]
== dummy_actor.queue_name
)
assert segment["status"] == ("error" if task_fails else "ok")
else:
if task_fails:
Expand All @@ -184,6 +188,10 @@ def dummy_actor(x, y):
assert event["type"] == "transaction"
assert event["transaction"] == "dummy_actor"
assert event["transaction_info"] == {"source": TransactionSource.TASK}
assert (
event["contexts"]["trace"]["data"][SPANDATA.MESSAGING_DESTINATION_NAME]
== dummy_actor.queue_name
)
assert event["contexts"]["trace"]["status"] == expected_span_status


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