Skip to content

Commit fe39dbb

Browse files
chore: Replace framework-specific queue ops (#7959)
1 parent 5474424 commit fe39dbb

15 files changed

Lines changed: 72 additions & 61 deletions

File tree

‎MIGRATION_GUIDE.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ Span ops are now a smaller, framework-neutral set.
4444
- The Cohere integration now emits `gen_ai.chat` instead of `ai.chat_completions.create.cohere`, and `gen_ai.embeddings` instead of `ai.embeddings.create.cohere`.
4545
- The Django integration now emits `view.render` instead of `view.response.render`, `view` instead of `view.authenticate`, and `function` instead of `event.django`.
4646
- The Django, Starlette, Starlite, and Litestar integrations now emit `middleware` instead of `middleware.django`, `middleware.starlette`, `middleware.starlette.receive`, `middleware.starlette.send`, `middleware.starlite`, `middleware.starlite.receive`, `middleware.starlite.send`, `middleware.litestar`, `middleware.litestar.receive`, and `middleware.litestar.send`.
47+
- The ARQ, Celery, Django, Dramatiq, Huey, RQ, and Ray integrations now emit `queue.publish` and `queue.process` instead of `queue.submit.arq`, `queue.task.arq`, `queue.submit.celery`, `queue.task.celery`, `queue.submit.django`, `queue.task.dramatiq`, `queue.submit.huey`, `queue.task.huey`, `queue.task.rq`, `queue.submit.ray`, and `queue.task.ray`.
4748

4849
#### Django
4950

‎sentry_sdk/integrations/arq.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ async def _sentry_enqueue_job(
8080
with sentry_sdk.start_span(
8181
name=function,
8282
attributes={
83-
"sentry.op": OP.QUEUE_SUBMIT_ARQ,
83+
"sentry.op": OP.QUEUE_PUBLISH,
8484
"sentry.origin": ArqIntegration.origin,
8585
},
8686
):
@@ -105,7 +105,7 @@ async def _sentry_run_job(self: "Worker", job_id: str, score: int) -> None:
105105
with sentry_sdk.start_span(
106106
name="unknown arq task",
107107
attributes={
108-
"sentry.op": OP.QUEUE_TASK_ARQ,
108+
"sentry.op": OP.QUEUE_PROCESS,
109109
"sentry.origin": ArqIntegration.origin,
110110
"sentry.segment.name.source": SegmentNameSource.TASK,
111111
SPANDATA.MESSAGING_MESSAGE_ID: job_id,

‎sentry_sdk/integrations/celery/__init__.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ def apply_async(*args: "Any", **kwargs: "Any") -> "Any":
267267
span = sentry_sdk.start_span(
268268
name=task_name,
269269
attributes={
270-
"sentry.op": OP.QUEUE_SUBMIT_CELERY,
270+
"sentry.op": OP.QUEUE_PUBLISH,
271271
"sentry.origin": CeleryIntegration.origin,
272272
},
273273
)
@@ -329,7 +329,7 @@ def _inner(*args: "Any", **kwargs: "Any") -> "Any":
329329
attributes={
330330
"sentry.origin": CeleryIntegration.origin,
331331
"sentry.segment.name.source": SegmentNameSource.TASK.value,
332-
"sentry.op": OP.QUEUE_TASK_CELERY,
332+
"sentry.op": OP.QUEUE_PROCESS,
333333
},
334334
)
335335

‎sentry_sdk/integrations/django/tasks.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def _sentry_enqueue(self: "Any", *args: "Any", **kwargs: "Any") -> "Any":
3838
with sentry_sdk.start_span(
3939
name=name,
4040
attributes={
41-
"sentry.op": OP.QUEUE_SUBMIT_DJANGO,
41+
"sentry.op": OP.QUEUE_PUBLISH,
4242
"sentry.origin": DjangoIntegration.origin,
4343
},
4444
):

‎sentry_sdk/integrations/dramatiq.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def before_process_message(self, broker: "Broker", message: "Message[R]") -> Non
141141
span = sentry_sdk.start_span(
142142
name=message.actor_name,
143143
attributes={
144-
"sentry.op": OP.QUEUE_TASK_DRAMATIQ,
144+
"sentry.op": OP.QUEUE_PROCESS,
145145
"sentry.origin": DramatiqIntegration.origin,
146146
"sentry.segment.name.source": SegmentNameSource.TASK.value,
147147
SPANDATA.MESSAGING_DESTINATION_NAME: message.queue_name,

‎sentry_sdk/integrations/huey.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def _sentry_enqueue(
9393
with sentry_sdk.start_span(
9494
name=span_name,
9595
attributes={
96-
"sentry.op": OP.QUEUE_SUBMIT_HUEY,
96+
"sentry.op": OP.QUEUE_PUBLISH,
9797
"sentry.origin": HueyIntegration.origin,
9898
SPANDATA.MESSAGING_DESTINATION_NAME: self.name,
9999
},
@@ -191,7 +191,7 @@ def _sentry_execute(
191191
span_ctx = sentry_sdk.start_span(
192192
name=task.name,
193193
attributes={
194-
"sentry.op": OP.QUEUE_TASK_HUEY,
194+
"sentry.op": OP.QUEUE_PROCESS,
195195
"sentry.origin": HueyIntegration.origin,
196196
"sentry.segment.name.source": SegmentNameSource.TASK,
197197
SPANDATA.MESSAGING_DESTINATION_NAME: self.name,

‎sentry_sdk/integrations/ray.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def new_func(
9595
with sentry_sdk.start_span(
9696
name="unknown Ray task" if function_name is None else function_name,
9797
attributes={
98-
"sentry.op": OP.QUEUE_TASK_RAY,
98+
"sentry.op": OP.QUEUE_PROCESS,
9999
"sentry.origin": RayIntegration.origin,
100100
"sentry.segment.name.source": SegmentNameSource.TASK,
101101
},
@@ -145,7 +145,7 @@ def _remote_method_with_header_propagation(
145145
with sentry_sdk.start_span(
146146
name="unknown Ray task" if function_name is None else function_name,
147147
attributes={
148-
"sentry.op": OP.QUEUE_SUBMIT_RAY,
148+
"sentry.op": OP.QUEUE_PUBLISH,
149149
"sentry.origin": RayIntegration.origin,
150150
},
151151
):

‎sentry_sdk/integrations/rq.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def sentry_patched_perform_job(
8282
with sentry_sdk.start_span(
8383
name="unknown RQ task" if func_name is None else func_name,
8484
attributes={
85-
"sentry.op": OP.QUEUE_TASK_RQ,
85+
"sentry.op": OP.QUEUE_PROCESS,
8686
"sentry.origin": RqIntegration.origin,
8787
"sentry.segment.name.source": SegmentNameSource.TASK,
8888
SPANDATA.MESSAGING_MESSAGE_ID: job.id,

‎tests/integrations/arq/test_arq.py‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
import sentry_sdk
1313
from sentry_sdk import get_client
14-
from sentry_sdk.consts import SPANDATA
14+
from sentry_sdk.consts import OP, SPANDATA
1515
from sentry_sdk.integrations.arq import ArqIntegration
1616
from tests.integrations.utils import DATA_COLLECTION_QUEUES_CASES
1717

@@ -244,10 +244,10 @@ async def retry_job(ctx):
244244
spans = [item.payload for item in items]
245245

246246
# The retry re-enqueue happens without an active span, so no producer
247-
# (queue.submit.arq) span is created for it; only the consumer segment
247+
# (queue.publish) span is created for it; only the consumer segment
248248
# is emitted. The consumer segment is preceded by the redis spans for
249249
# the re-enqueue, so it lands at index 2.
250-
assert spans[2]["attributes"]["sentry.op"] == "queue.task.arq"
250+
assert spans[2]["attributes"]["sentry.op"] == OP.QUEUE_PROCESS
251251
assert spans[2]["status"] == "ok"
252252
assert spans[2]["name"] == "retry_job"
253253

@@ -256,7 +256,7 @@ async def retry_job(ctx):
256256
sentry_sdk.flush()
257257
spans = [item.payload for item in items]
258258

259-
assert spans[5]["attributes"]["sentry.op"] == "queue.task.arq"
259+
assert spans[5]["attributes"]["sentry.op"] == OP.QUEUE_PROCESS
260260
assert spans[5]["status"] == "ok"
261261
assert spans[5]["name"] == "retry_job"
262262

@@ -329,7 +329,7 @@ async def division(_, a, b=0):
329329
task_spans = [
330330
span
331331
for span in spans
332-
if span["attributes"].get("sentry.op") == "queue.task.arq"
332+
if span["attributes"].get("sentry.op") == OP.QUEUE_PROCESS
333333
]
334334

335335
division_span = next(span for span in task_spans if span["name"] == "division")
@@ -413,7 +413,7 @@ async def dummy_job(_):
413413
assert spans[2]["trace_id"] == span.trace_id
414414
assert spans[2]["span_id"] == span.span_id
415415

416-
assert spans[1]["attributes"]["sentry.op"] == "queue.submit.arq"
416+
assert spans[1]["attributes"]["sentry.op"] == OP.QUEUE_PUBLISH
417417
assert spans[1]["name"] == "dummy_job"
418418

419419

@@ -497,10 +497,10 @@ async def job(ctx):
497497
sentry_sdk.flush()
498498
spans = [item.payload for item in items]
499499

500-
# No producer (queue.submit.arq) span is created for the re-enqueue
500+
# No producer (queue.publish) span is created for the re-enqueue
501501
# triggered by the retry, since it happens without an active span, so
502502
# the consumer segment lands at index 2.
503-
assert spans[2]["attributes"]["sentry.op"] == "queue.task.arq"
503+
assert spans[2]["attributes"]["sentry.op"] == OP.QUEUE_PROCESS
504504
assert spans[2]["attributes"]["sentry.origin"] == "auto.queue.arq"
505505
assert spans[1]["attributes"]["sentry.origin"] == "auto.db.redis"
506506
assert spans[0]["attributes"]["sentry.origin"] == "auto.db.redis"

‎tests/integrations/celery/test_celery.py‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from celery.exceptions import Ignore, Reject, Retry
1010

1111
import sentry_sdk
12+
from sentry_sdk.consts import OP
1213
from sentry_sdk.integrations.celery import (
1314
CeleryIntegration,
1415
_wrap_task_run,
@@ -297,14 +298,14 @@ def dummy_task(x, y):
297298

298299
assert process_span["name"] == "dummy_task"
299300
assert process_span["trace_id"] == span.trace_id
300-
assert process_span["attributes"]["sentry.op"] == "queue.process"
301+
assert process_span["attributes"]["sentry.op"] == OP.QUEUE_PROCESS
301302
assert process_span["parent_span_id"] == execution_span["span_id"]
302303

303304
assert submission_span["name"] == "submission"
304305
assert submission_span["is_segment"] is True
305306

306307
assert submit_span["name"] == "dummy_task"
307-
assert submit_span["attributes"]["sentry.op"] == "queue.submit.celery"
308+
assert submit_span["attributes"]["sentry.op"] == OP.QUEUE_PUBLISH
308309
assert submit_span["attributes"]["sentry.origin"] == "auto.queue.celery"
309310
assert submit_span["parent_span_id"] == submission_span["span_id"] == span.span_id
310311
assert submit_span["trace_id"] == span.trace_id
@@ -434,7 +435,7 @@ def dummy_task():
434435
assert not [item for item in items if item.type == "event"]
435436

436437
process_span, execution_span = [item.payload for item in items]
437-
assert process_span["attributes"]["sentry.op"] == "queue.process"
438+
assert process_span["attributes"]["sentry.op"] == OP.QUEUE_PROCESS
438439
assert process_span["status"] == "ok"
439440
assert execution_span["is_segment"] is True
440441
assert execution_span["status"] == "ok"
@@ -809,7 +810,7 @@ def task(): ...
809810

810811
span_items = [item.payload for item in items]
811812
publish_span = next(
812-
s for s in span_items if s["attributes"].get("sentry.op") == "queue.publish"
813+
s for s in span_items if s["attributes"].get("sentry.op") == OP.QUEUE_PUBLISH
813814
)
814815

815816
assert publish_span["attributes"]["messaging.system"] == system
@@ -941,7 +942,7 @@ def test_send_task_wrapped(
941942
assert outer["is_segment"] is True
942943

943944
assert submit_span["name"] == "very_creative_task_name"
944-
assert submit_span["attributes"]["sentry.op"] == "queue.submit.celery"
945+
assert submit_span["attributes"]["sentry.op"] == OP.QUEUE_PUBLISH
945946
assert submit_span["trace_id"] == outer_span.trace_id
946947
assert submit_span["trace_id"] == kwargs["headers"]["sentry-trace"].split("-")[0]
947948

0 commit comments

Comments
 (0)