diff --git a/MIGRATION_GUIDE.md b/MIGRATION_GUIDE.md index 8031b82ee3..f753ae88d1 100644 --- a/MIGRATION_GUIDE.md +++ b/MIGRATION_GUIDE.md @@ -44,6 +44,7 @@ Span ops are now a smaller, framework-neutral set. - 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`. - The Django integration now emits `view.render` instead of `view.response.render`, `view` instead of `view.authenticate`, and `function` instead of `event.django`. - 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`. +- 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`. #### Django diff --git a/sentry_sdk/integrations/arq.py b/sentry_sdk/integrations/arq.py index 5cdbf9892d..65079e37e2 100644 --- a/sentry_sdk/integrations/arq.py +++ b/sentry_sdk/integrations/arq.py @@ -80,7 +80,7 @@ async def _sentry_enqueue_job( with sentry_sdk.start_span( name=function, attributes={ - "sentry.op": OP.QUEUE_SUBMIT_ARQ, + "sentry.op": OP.QUEUE_PUBLISH, "sentry.origin": ArqIntegration.origin, }, ): @@ -105,7 +105,7 @@ async def _sentry_run_job(self: "Worker", job_id: str, score: int) -> None: with sentry_sdk.start_span( name="unknown arq task", attributes={ - "sentry.op": OP.QUEUE_TASK_ARQ, + "sentry.op": OP.QUEUE_PROCESS, "sentry.origin": ArqIntegration.origin, "sentry.segment.name.source": SegmentNameSource.TASK, SPANDATA.MESSAGING_MESSAGE_ID: job_id, diff --git a/sentry_sdk/integrations/celery/__init__.py b/sentry_sdk/integrations/celery/__init__.py index faf9c9e855..0af21c18cd 100644 --- a/sentry_sdk/integrations/celery/__init__.py +++ b/sentry_sdk/integrations/celery/__init__.py @@ -267,7 +267,7 @@ def apply_async(*args: "Any", **kwargs: "Any") -> "Any": span = sentry_sdk.start_span( name=task_name, attributes={ - "sentry.op": OP.QUEUE_SUBMIT_CELERY, + "sentry.op": OP.QUEUE_PUBLISH, "sentry.origin": CeleryIntegration.origin, }, ) @@ -329,7 +329,7 @@ def _inner(*args: "Any", **kwargs: "Any") -> "Any": attributes={ "sentry.origin": CeleryIntegration.origin, "sentry.segment.name.source": SegmentNameSource.TASK.value, - "sentry.op": OP.QUEUE_TASK_CELERY, + "sentry.op": OP.QUEUE_PROCESS, }, ) diff --git a/sentry_sdk/integrations/django/tasks.py b/sentry_sdk/integrations/django/tasks.py index d1fdc72854..4b8c019244 100644 --- a/sentry_sdk/integrations/django/tasks.py +++ b/sentry_sdk/integrations/django/tasks.py @@ -38,7 +38,7 @@ def _sentry_enqueue(self: "Any", *args: "Any", **kwargs: "Any") -> "Any": with sentry_sdk.start_span( name=name, attributes={ - "sentry.op": OP.QUEUE_SUBMIT_DJANGO, + "sentry.op": OP.QUEUE_PUBLISH, "sentry.origin": DjangoIntegration.origin, }, ): diff --git a/sentry_sdk/integrations/dramatiq.py b/sentry_sdk/integrations/dramatiq.py index 07c8130172..9fa625f9c8 100644 --- a/sentry_sdk/integrations/dramatiq.py +++ b/sentry_sdk/integrations/dramatiq.py @@ -141,7 +141,7 @@ def before_process_message(self, broker: "Broker", message: "Message[R]") -> Non span = sentry_sdk.start_span( name=message.actor_name, attributes={ - "sentry.op": OP.QUEUE_TASK_DRAMATIQ, + "sentry.op": OP.QUEUE_PROCESS, "sentry.origin": DramatiqIntegration.origin, "sentry.segment.name.source": SegmentNameSource.TASK.value, SPANDATA.MESSAGING_DESTINATION_NAME: message.queue_name, diff --git a/sentry_sdk/integrations/huey.py b/sentry_sdk/integrations/huey.py index d36b0566e1..db14e3bbe6 100644 --- a/sentry_sdk/integrations/huey.py +++ b/sentry_sdk/integrations/huey.py @@ -93,7 +93,7 @@ def _sentry_enqueue( with sentry_sdk.start_span( name=span_name, attributes={ - "sentry.op": OP.QUEUE_SUBMIT_HUEY, + "sentry.op": OP.QUEUE_PUBLISH, "sentry.origin": HueyIntegration.origin, SPANDATA.MESSAGING_DESTINATION_NAME: self.name, }, @@ -191,7 +191,7 @@ def _sentry_execute( span_ctx = sentry_sdk.start_span( name=task.name, attributes={ - "sentry.op": OP.QUEUE_TASK_HUEY, + "sentry.op": OP.QUEUE_PROCESS, "sentry.origin": HueyIntegration.origin, "sentry.segment.name.source": SegmentNameSource.TASK, SPANDATA.MESSAGING_DESTINATION_NAME: self.name, diff --git a/sentry_sdk/integrations/ray.py b/sentry_sdk/integrations/ray.py index 108a90dfc9..ec7cb433b8 100644 --- a/sentry_sdk/integrations/ray.py +++ b/sentry_sdk/integrations/ray.py @@ -95,7 +95,7 @@ def new_func( with sentry_sdk.start_span( name="unknown Ray task" if function_name is None else function_name, attributes={ - "sentry.op": OP.QUEUE_TASK_RAY, + "sentry.op": OP.QUEUE_PROCESS, "sentry.origin": RayIntegration.origin, "sentry.segment.name.source": SegmentNameSource.TASK, }, @@ -145,7 +145,7 @@ def _remote_method_with_header_propagation( with sentry_sdk.start_span( name="unknown Ray task" if function_name is None else function_name, attributes={ - "sentry.op": OP.QUEUE_SUBMIT_RAY, + "sentry.op": OP.QUEUE_PUBLISH, "sentry.origin": RayIntegration.origin, }, ): diff --git a/sentry_sdk/integrations/rq.py b/sentry_sdk/integrations/rq.py index c656c19cf0..337d38a49f 100644 --- a/sentry_sdk/integrations/rq.py +++ b/sentry_sdk/integrations/rq.py @@ -82,7 +82,7 @@ def sentry_patched_perform_job( with sentry_sdk.start_span( name="unknown RQ task" if func_name is None else func_name, attributes={ - "sentry.op": OP.QUEUE_TASK_RQ, + "sentry.op": OP.QUEUE_PROCESS, "sentry.origin": RqIntegration.origin, "sentry.segment.name.source": SegmentNameSource.TASK, SPANDATA.MESSAGING_MESSAGE_ID: job.id, diff --git a/tests/integrations/arq/test_arq.py b/tests/integrations/arq/test_arq.py index 1cbf5c1a4d..8c0908746c 100644 --- a/tests/integrations/arq/test_arq.py +++ b/tests/integrations/arq/test_arq.py @@ -11,7 +11,7 @@ import sentry_sdk from sentry_sdk import get_client -from sentry_sdk.consts import SPANDATA +from sentry_sdk.consts import OP, SPANDATA from sentry_sdk.integrations.arq import ArqIntegration from tests.integrations.utils import DATA_COLLECTION_QUEUES_CASES @@ -244,10 +244,10 @@ async def retry_job(ctx): spans = [item.payload for item in items] # The retry re-enqueue happens without an active span, so no producer - # (queue.submit.arq) span is created for it; only the consumer segment + # (queue.publish) span is created for it; only the consumer segment # is emitted. The consumer segment is preceded by the redis spans for # the re-enqueue, so it lands at index 2. - assert spans[2]["attributes"]["sentry.op"] == "queue.task.arq" + assert spans[2]["attributes"]["sentry.op"] == OP.QUEUE_PROCESS assert spans[2]["status"] == "ok" assert spans[2]["name"] == "retry_job" @@ -256,7 +256,7 @@ async def retry_job(ctx): sentry_sdk.flush() spans = [item.payload for item in items] - assert spans[5]["attributes"]["sentry.op"] == "queue.task.arq" + assert spans[5]["attributes"]["sentry.op"] == OP.QUEUE_PROCESS assert spans[5]["status"] == "ok" assert spans[5]["name"] == "retry_job" @@ -329,7 +329,7 @@ async def division(_, a, b=0): task_spans = [ span for span in spans - if span["attributes"].get("sentry.op") == "queue.task.arq" + if span["attributes"].get("sentry.op") == OP.QUEUE_PROCESS ] division_span = next(span for span in task_spans if span["name"] == "division") @@ -413,7 +413,7 @@ async def dummy_job(_): assert spans[2]["trace_id"] == span.trace_id assert spans[2]["span_id"] == span.span_id - assert spans[1]["attributes"]["sentry.op"] == "queue.submit.arq" + assert spans[1]["attributes"]["sentry.op"] == OP.QUEUE_PUBLISH assert spans[1]["name"] == "dummy_job" @@ -497,10 +497,10 @@ async def job(ctx): sentry_sdk.flush() spans = [item.payload for item in items] - # No producer (queue.submit.arq) span is created for the re-enqueue + # No producer (queue.publish) span is created for the re-enqueue # triggered by the retry, since it happens without an active span, so # the consumer segment lands at index 2. - assert spans[2]["attributes"]["sentry.op"] == "queue.task.arq" + assert spans[2]["attributes"]["sentry.op"] == OP.QUEUE_PROCESS assert spans[2]["attributes"]["sentry.origin"] == "auto.queue.arq" assert spans[1]["attributes"]["sentry.origin"] == "auto.db.redis" assert spans[0]["attributes"]["sentry.origin"] == "auto.db.redis" diff --git a/tests/integrations/celery/test_celery.py b/tests/integrations/celery/test_celery.py index 07208c6a7d..e5973372a9 100644 --- a/tests/integrations/celery/test_celery.py +++ b/tests/integrations/celery/test_celery.py @@ -9,6 +9,7 @@ from celery.exceptions import Ignore, Reject, Retry import sentry_sdk +from sentry_sdk.consts import OP from sentry_sdk.integrations.celery import ( CeleryIntegration, _wrap_task_run, @@ -297,14 +298,14 @@ def dummy_task(x, y): assert process_span["name"] == "dummy_task" assert process_span["trace_id"] == span.trace_id - assert process_span["attributes"]["sentry.op"] == "queue.process" + assert process_span["attributes"]["sentry.op"] == OP.QUEUE_PROCESS assert process_span["parent_span_id"] == execution_span["span_id"] assert submission_span["name"] == "submission" assert submission_span["is_segment"] is True assert submit_span["name"] == "dummy_task" - assert submit_span["attributes"]["sentry.op"] == "queue.submit.celery" + assert submit_span["attributes"]["sentry.op"] == OP.QUEUE_PUBLISH assert submit_span["attributes"]["sentry.origin"] == "auto.queue.celery" assert submit_span["parent_span_id"] == submission_span["span_id"] == span.span_id assert submit_span["trace_id"] == span.trace_id @@ -434,7 +435,7 @@ def dummy_task(): assert not [item for item in items if item.type == "event"] process_span, execution_span = [item.payload for item in items] - assert process_span["attributes"]["sentry.op"] == "queue.process" + assert process_span["attributes"]["sentry.op"] == OP.QUEUE_PROCESS assert process_span["status"] == "ok" assert execution_span["is_segment"] is True assert execution_span["status"] == "ok" @@ -809,7 +810,7 @@ def task(): ... span_items = [item.payload for item in items] publish_span = next( - s for s in span_items if s["attributes"].get("sentry.op") == "queue.publish" + s for s in span_items if s["attributes"].get("sentry.op") == OP.QUEUE_PUBLISH ) assert publish_span["attributes"]["messaging.system"] == system @@ -941,7 +942,7 @@ def test_send_task_wrapped( assert outer["is_segment"] is True assert submit_span["name"] == "very_creative_task_name" - assert submit_span["attributes"]["sentry.op"] == "queue.submit.celery" + assert submit_span["attributes"]["sentry.op"] == OP.QUEUE_PUBLISH assert submit_span["trace_id"] == outer_span.trace_id assert submit_span["trace_id"] == kwargs["headers"]["sentry-trace"].split("-")[0] diff --git a/tests/integrations/django/test_tasks.py b/tests/integrations/django/test_tasks.py index f080d7872c..17a1ac6912 100644 --- a/tests/integrations/django/test_tasks.py +++ b/tests/integrations/django/test_tasks.py @@ -59,7 +59,7 @@ def test_task_span_is_created( capture_items, immediate_backend, ): - """Test that the queue.submit.django span is created when a task is enqueued.""" + """Test that the queue.publish span is created when a task is enqueued.""" sentry_init( integrations=[DjangoIntegration()], traces_sample_rate=1.0, @@ -75,7 +75,7 @@ def test_task_span_is_created( queue_submit_spans = [ span for span in spans - if span["attributes"].get("sentry.op") == OP.QUEUE_SUBMIT_DJANGO + if span["attributes"].get("sentry.op") == OP.QUEUE_PUBLISH ] assert len(queue_submit_spans) == 1 assert ( @@ -129,7 +129,7 @@ def test_task_enqueue_with_kwargs( queue_submit_spans = [ span for span in spans - if span["attributes"].get("sentry.op") == OP.QUEUE_SUBMIT_DJANGO + if span["attributes"].get("sentry.op") == OP.QUEUE_PUBLISH ] assert len(queue_submit_spans) == 1 assert queue_submit_spans[0]["name"] == "tests.integrations.django.test_tasks.greet" @@ -166,7 +166,7 @@ def test_task_error_reporting( queue_submit_spans = [ span for span in spans - if span["attributes"].get("sentry.op") == OP.QUEUE_SUBMIT_DJANGO + if span["attributes"].get("sentry.op") == OP.QUEUE_PUBLISH ] assert len(queue_submit_spans) == 1 @@ -203,7 +203,7 @@ def test_multiple_task_enqueues_create_multiple_spans( queue_submit_spans = [ span for span in spans - if span["attributes"].get("sentry.op") == OP.QUEUE_SUBMIT_DJANGO + if span["attributes"].get("sentry.op") == OP.QUEUE_PUBLISH ] assert len(queue_submit_spans) == 3 diff --git a/tests/integrations/dramatiq/test_dramatiq.py b/tests/integrations/dramatiq/test_dramatiq.py index 7ea46957da..ed644fe447 100644 --- a/tests/integrations/dramatiq/test_dramatiq.py +++ b/tests/integrations/dramatiq/test_dramatiq.py @@ -6,7 +6,7 @@ from dramatiq.middleware import Middleware, SkipMessage import sentry_sdk -from sentry_sdk.consts import SPANDATA +from sentry_sdk.consts import OP, SPANDATA from sentry_sdk.integrations.dramatiq import DramatiqIntegration from sentry_sdk.integrations.logging import ignore_logger_for_events @@ -146,7 +146,7 @@ def dummy_actor(x, y): assert segment_item.type == "span" assert segment["name"] == "dummy_actor" assert segment["is_segment"] is True - assert segment["attributes"]["sentry.op"] == "queue.task.dramatiq" + assert segment["attributes"]["sentry.op"] == OP.QUEUE_PROCESS assert segment["attributes"]["sentry.segment.name.source"] == "task" assert ( segment["attributes"][SPANDATA.MESSAGING_DESTINATION_NAME] @@ -181,7 +181,7 @@ def propagated_trace_task(): inner_segment, outer_segment = [i.payload for i in items] assert inner_segment["name"] == "propagated_trace_task" - assert inner_segment["attributes"]["sentry.op"] == "queue.task.dramatiq" + assert inner_segment["attributes"]["sentry.op"] == OP.QUEUE_PROCESS assert inner_segment["trace_id"] == outer_span.trace_id assert outer_segment["name"] == "outer" diff --git a/tests/integrations/huey/test_huey.py b/tests/integrations/huey/test_huey.py index de47ee7303..a6cae1b192 100644 --- a/tests/integrations/huey/test_huey.py +++ b/tests/integrations/huey/test_huey.py @@ -90,13 +90,13 @@ def division(a, b): payloads = [i.payload for i in items] # The task is enqueued without a wrapping span, so in streaming mode no - # producer (queue.submit.huey) span is created (see the early return in + # producer (queue.publish) span is created (see the early return in # patch_enqueue). Only the consumer segment is emitted. assert len(payloads) == 1 (execute_span,) = payloads assert execute_span["is_segment"] - assert execute_span["attributes"]["sentry.op"] == OP.QUEUE_TASK_HUEY + assert execute_span["attributes"]["sentry.op"] == OP.QUEUE_PROCESS 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) @@ -125,10 +125,10 @@ def retry_task(context): re_enqueue_span, execute_span = payloads - assert re_enqueue_span["attributes"]["sentry.op"] == OP.QUEUE_SUBMIT_HUEY + assert re_enqueue_span["attributes"]["sentry.op"] == OP.QUEUE_PUBLISH assert not re_enqueue_span["is_segment"] - assert execute_span["attributes"]["sentry.op"] == OP.QUEUE_TASK_HUEY + assert execute_span["attributes"]["sentry.op"] == OP.QUEUE_PROCESS assert execute_span["is_segment"] assert execute_span["name"] == "retry_task" assert execute_span["status"] == SpanStatus.OK @@ -167,7 +167,7 @@ def cancel_task(): assert len(payloads) == 1 (execute_span,) = payloads - assert execute_span["attributes"]["sentry.op"] == OP.QUEUE_TASK_HUEY + assert execute_span["attributes"]["sentry.op"] == OP.QUEUE_PROCESS assert execute_span["is_segment"] assert execute_span["name"] == "cancel_task" assert execute_span["status"] == SpanStatus.OK @@ -198,7 +198,7 @@ def maybe_locked_task(): assert len(payloads) == 1 (execute_span,) = payloads - assert execute_span["attributes"]["sentry.op"] == OP.QUEUE_TASK_HUEY + assert execute_span["attributes"]["sentry.op"] == OP.QUEUE_PROCESS assert execute_span["is_segment"] assert execute_span["name"] == "maybe_locked_task" @@ -260,14 +260,14 @@ def dummy_task(): enqueue_span = next( p for p in payloads - if p.get("attributes", {}).get("sentry.op") == OP.QUEUE_SUBMIT_HUEY + if p.get("attributes", {}).get("sentry.op") == OP.QUEUE_PUBLISH ) segment_span = next(p for p in payloads if p.get("is_segment")) assert enqueue_span["trace_id"] == segment_span["trace_id"] assert enqueue_span["parent_span_id"] == segment_span["span_id"] assert enqueue_span["name"] == "different_task_name" - assert enqueue_span["attributes"]["sentry.op"] == OP.QUEUE_SUBMIT_HUEY + assert enqueue_span["attributes"]["sentry.op"] == OP.QUEUE_PUBLISH assert enqueue_span["attributes"][SPANDATA.MESSAGING_DESTINATION_NAME] == huey.name @@ -291,7 +291,7 @@ def propagated_trace_task(): execute_span = next( p for p in payloads - if p.get("attributes", {}).get("sentry.op") == OP.QUEUE_TASK_HUEY + if p.get("attributes", {}).get("sentry.op") == OP.QUEUE_PROCESS ) assert execute_span["name"] == "propagated_trace_task" @@ -317,7 +317,7 @@ def dummy_task(): enqueue_span = next( p for p in payloads - if p.get("attributes", {}).get("sentry.op") == OP.QUEUE_SUBMIT_HUEY + if p.get("attributes", {}).get("sentry.op") == OP.QUEUE_PUBLISH ) assert enqueue_span["attributes"]["sentry.origin"] == "auto.queue.huey" @@ -341,7 +341,7 @@ def propagated_trace_task(): execute_span = next( p for p in payloads - if p.get("attributes", {}).get("sentry.op") == OP.QUEUE_TASK_HUEY + if p.get("attributes", {}).get("sentry.op") == OP.QUEUE_PROCESS ) assert execute_span["attributes"]["sentry.origin"] == "auto.queue.huey" @@ -393,28 +393,28 @@ def task2(): assert group_span["parent_span_id"] == submission_span["span_id"] assert group_span["name"] == "Huey Task Group" assert group_span["status"] == "ok" - assert group_span["attributes"]["sentry.op"] == "queue.submit.huey" + assert group_span["attributes"]["sentry.op"] == OP.QUEUE_PUBLISH assert group_span["attributes"]["sentry.origin"] == "auto.queue.huey" assert task1_enqueue_span["name"] == "task1" assert task1_enqueue_span["status"] == "ok" assert task1_enqueue_span["parent_span_id"] == group_span["span_id"] assert task1_enqueue_span["attributes"]["sentry.segment.name"] == "submission" - assert task1_enqueue_span["attributes"]["sentry.op"] == "queue.submit.huey" + assert task1_enqueue_span["attributes"]["sentry.op"] == OP.QUEUE_PUBLISH assert task1_enqueue_span["attributes"]["sentry.origin"] == "auto.queue.huey" assert task2_enqueue_span["name"] == "task2" assert task2_enqueue_span["status"] == "ok" assert task2_enqueue_span["parent_span_id"] == group_span["span_id"] assert task2_enqueue_span["attributes"]["sentry.segment.name"] == "submission" - assert task2_enqueue_span["attributes"]["sentry.op"] == "queue.submit.huey" + assert task2_enqueue_span["attributes"]["sentry.op"] == OP.QUEUE_PUBLISH assert task2_enqueue_span["attributes"]["sentry.origin"] == "auto.queue.huey" assert task1_execute_span["name"] == "task1" assert task1_execute_span["status"] == "ok" assert task1_execute_span["attributes"]["messaging.message.system"] == "huey" assert task1_execute_span["parent_span_id"] == task1_enqueue_span["span_id"] - assert task1_execute_span["attributes"]["sentry.op"] == "queue.task.huey" + assert task1_execute_span["attributes"]["sentry.op"] == OP.QUEUE_PROCESS assert task1_execute_span["attributes"]["sentry.origin"] == "auto.queue.huey" assert ( task1_execute_span["attributes"]["sentry.segment.name.source"] @@ -427,7 +427,7 @@ def task2(): assert task2_execute_span["status"] == "ok" assert task2_execute_span["parent_span_id"] == task2_enqueue_span["span_id"] assert task2_execute_span["attributes"]["messaging.message.system"] == "huey" - assert task2_execute_span["attributes"]["sentry.op"] == "queue.task.huey" + assert task2_execute_span["attributes"]["sentry.op"] == OP.QUEUE_PROCESS assert task2_execute_span["attributes"]["sentry.origin"] == "auto.queue.huey" assert ( task2_execute_span["attributes"]["sentry.segment.name.source"] @@ -480,21 +480,21 @@ def task2(results): assert chord_span["parent_span_id"] == submission_span["span_id"] assert chord_span["name"] == "Huey Chord" assert chord_span["status"] == "ok" - assert chord_span["attributes"]["sentry.op"] == "queue.submit.huey" + assert chord_span["attributes"]["sentry.op"] == OP.QUEUE_PUBLISH assert chord_span["attributes"]["sentry.origin"] == "auto.queue.huey" assert task1_enqueue_span["name"] == "task1" assert task1_enqueue_span["status"] == "ok" assert task1_enqueue_span["parent_span_id"] == chord_span["span_id"] assert task1_enqueue_span["attributes"]["sentry.segment.name"] == "submission" - assert task1_enqueue_span["attributes"]["sentry.op"] == "queue.submit.huey" + assert task1_enqueue_span["attributes"]["sentry.op"] == OP.QUEUE_PUBLISH assert task1_enqueue_span["attributes"]["sentry.origin"] == "auto.queue.huey" assert task1_execute_span["name"] == "task1" assert task1_execute_span["status"] == "ok" assert task1_execute_span["attributes"]["messaging.message.system"] == "huey" assert task1_execute_span["parent_span_id"] == task1_enqueue_span["span_id"] - assert task1_execute_span["attributes"]["sentry.op"] == "queue.task.huey" + assert task1_execute_span["attributes"]["sentry.op"] == OP.QUEUE_PROCESS assert task1_execute_span["attributes"]["sentry.origin"] == "auto.queue.huey" assert ( task1_execute_span["attributes"]["sentry.segment.name.source"] @@ -505,14 +505,14 @@ def task2(results): assert task2_enqueue_span["status"] == "ok" assert task2_enqueue_span["parent_span_id"] == task1_execute_span["span_id"] assert task2_enqueue_span["attributes"]["sentry.segment.name"] == "task1" - assert task2_enqueue_span["attributes"]["sentry.op"] == "queue.submit.huey" + assert task2_enqueue_span["attributes"]["sentry.op"] == OP.QUEUE_PUBLISH assert task2_enqueue_span["attributes"]["sentry.origin"] == "auto.queue.huey" assert task2_execute_span["name"] == "task2" assert task2_execute_span["status"] == "ok" assert task2_execute_span["parent_span_id"] == task2_enqueue_span["span_id"] assert task2_execute_span["attributes"]["messaging.message.system"] == "huey" - assert task2_execute_span["attributes"]["sentry.op"] == "queue.task.huey" + assert task2_execute_span["attributes"]["sentry.op"] == OP.QUEUE_PROCESS assert task2_execute_span["attributes"]["sentry.origin"] == "auto.queue.huey" assert ( task2_execute_span["attributes"]["sentry.segment.name.source"] diff --git a/tests/integrations/ray/test_ray.py b/tests/integrations/ray/test_ray.py index a4ce462e97..5c0b352eee 100644 --- a/tests/integrations/ray/test_ray.py +++ b/tests/integrations/ray/test_ray.py @@ -8,6 +8,7 @@ import ray import sentry_sdk +from sentry_sdk.consts import OP from sentry_sdk.envelope import Envelope from sentry_sdk.integrations.ray import RayIntegration from sentry_sdk.integrations.stdlib import StdlibIntegration @@ -222,7 +223,7 @@ def test_tracing_in_ray_tasks( ) span = client_spans[0] - assert span["attributes"]["sentry.op"]["value"] == "queue.submit.ray" + assert span["attributes"]["sentry.op"]["value"] == OP.QUEUE_PUBLISH assert span["attributes"]["sentry.origin"]["value"] == "auto.queue.ray" assert span["name"] == f"tests.integrations.ray.test_ray.{task.__name__}" assert span["parent_span_id"] == client_spans[1]["span_id"] diff --git a/tests/integrations/rq/test_rq.py b/tests/integrations/rq/test_rq.py index 189a750098..eda55c5517 100644 --- a/tests/integrations/rq/test_rq.py +++ b/tests/integrations/rq/test_rq.py @@ -5,7 +5,7 @@ from fakeredis import FakeRedis import sentry_sdk -from sentry_sdk.consts import SPANDATA +from sentry_sdk.consts import OP, SPANDATA from sentry_sdk.integrations.rq import RqIntegration from sentry_sdk.utils import parse_version from tests.integrations.utils import DATA_COLLECTION_QUEUES_CASES @@ -159,7 +159,7 @@ def test_worker_span_with_error( (error_event,) = (item.payload for item in items if item.type == "event") assert error_event["transaction"] == "tests.integrations.rq.test_rq.chew_up_shoes" - assert error_event["contexts"]["trace"]["op"] == "queue.task.rq" + assert error_event["contexts"]["trace"]["op"] == OP.QUEUE_PROCESS assert error_event["exception"]["values"][0]["type"] == "Exception" assert ( error_event["exception"]["values"][0]["value"] @@ -169,7 +169,9 @@ def test_worker_span_with_error( sentry_sdk.flush() spans = [item.payload for item in items if item.type == "span"] (span,) = ( - span for span in spans if span["attributes"].get("sentry.op") == "queue.task.rq" + span + for span in spans + if span["attributes"].get("sentry.op") == OP.QUEUE_PROCESS ) assert span["trace_id"] == error_event["contexts"]["trace"]["trace_id"] @@ -234,7 +236,9 @@ def test_tracing_enabled( sentry_sdk.flush() spans = [item.payload for item in items if item.type == "span"] (span,) = ( - span for span in spans if span["attributes"].get("sentry.op") == "queue.task.rq" + span + for span in spans + if span["attributes"].get("sentry.op") == OP.QUEUE_PROCESS ) assert span["trace_id"] == error_event["contexts"]["trace"]["trace_id"] @@ -285,10 +289,12 @@ def test_worker_span_no_error( sentry_sdk.flush() spans = [item.payload for item in items] (span,) = ( - span for span in spans if span["attributes"].get("sentry.op") == "queue.task.rq" + span + for span in spans + if span["attributes"].get("sentry.op") == OP.QUEUE_PROCESS ) - assert span["attributes"]["sentry.op"] == "queue.task.rq" + assert span["attributes"]["sentry.op"] == OP.QUEUE_PROCESS assert span["name"] == "tests.integrations.rq.test_rq.do_trick" assert span["attributes"][SPANDATA.MESSAGING_DESTINATION_NAME] == queue.name @@ -369,7 +375,9 @@ def test_span_origin( sentry_sdk.flush() spans = [item.payload for item in items] (span,) = ( - span for span in spans if span["attributes"].get("sentry.op") == "queue.task.rq" + span + for span in spans + if span["attributes"].get("sentry.op") == OP.QUEUE_PROCESS ) assert span["attributes"]["sentry.origin"] == "auto.queue.rq"