From e84577cd36de629e1df31e772385fae15a2104a9 Mon Sep 17 00:00:00 2001 From: Alexander Alderman Webb Date: Mon, 12 Oct 2026 14:45:04 +0200 Subject: [PATCH 1/3] chore: Replace deprecated event.django op with function --- .../integrations/django/signals_handlers.py | 2 +- tests/integrations/django/asgi/test_asgi.py | 2 +- tests/integrations/django/test_basic.py | 22 +++++++++---------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/sentry_sdk/integrations/django/signals_handlers.py b/sentry_sdk/integrations/django/signals_handlers.py index bbc76c9b4f..f9bfdb2456 100644 --- a/sentry_sdk/integrations/django/signals_handlers.py +++ b/sentry_sdk/integrations/django/signals_handlers.py @@ -69,7 +69,7 @@ def wrapper(*args: "Any", **kwargs: "Any") -> "Any": with sentry_sdk.start_span( name=signal_name, attributes={ - "sentry.op": OP.EVENT_DJANGO, + "sentry.op": OP.FUNCTION, "sentry.origin": DjangoIntegration.origin, SPANDATA.CODE_FUNCTION_NAME: signal_name, }, diff --git a/tests/integrations/django/asgi/test_asgi.py b/tests/integrations/django/asgi/test_asgi.py index df62d35288..cd0933e1a4 100644 --- a/tests/integrations/django/asgi/test_asgi.py +++ b/tests/integrations/django/asgi/test_asgi.py @@ -271,7 +271,7 @@ async def test_async_middleware_spans( # Filter out signal-receiver spans — their ordering depends on Django # module import order and is not what this middleware test verifies. - spans = [s for s in spans if s["attributes"].get("sentry.op") != "event.django"] + spans = [s for s in spans if s["attributes"].get("sentry.op") != "function"] assert ( render_span_tree(spans) diff --git a/tests/integrations/django/test_basic.py b/tests/integrations/django/test_basic.py index 44d604fe75..1a044ebd5c 100644 --- a/tests/integrations/django/test_basic.py +++ b/tests/integrations/django/test_basic.py @@ -1572,15 +1572,15 @@ def test_signals_spans( render_span_tree(spans) == """\ - sentry.op="http.server": name="/message" - - sentry.op="event.django": name="django.db.reset_queries" - - sentry.op="event.django": name="django.db.close_old_connections"\ + - sentry.op="function": name="django.db.reset_queries" + - sentry.op="function": name="django.db.close_old_connections"\ """ ) - assert spans[0]["attributes"]["sentry.op"] == "event.django" + assert spans[0]["attributes"]["sentry.op"] == "function" assert spans[0]["name"] == "django.db.reset_queries" - assert spans[1]["attributes"]["sentry.op"] == "event.django" + assert spans[1]["attributes"]["sentry.op"] == "function" assert spans[1]["name"] == "django.db.close_old_connections" @@ -1636,19 +1636,19 @@ def test_signals_spans_filtering( render_span_tree(spans) == """\ - sentry.op="http.server": name="/send-myapp-custom-signal" - - sentry.op="event.django": name="django.db.reset_queries" - - sentry.op="event.django": name="django.db.close_old_connections" - - sentry.op="event.django": name="tests.integrations.django.myapp.signals.signal_handler"\ + - sentry.op="function": name="django.db.reset_queries" + - sentry.op="function": name="django.db.close_old_connections" + - sentry.op="function": name="tests.integrations.django.myapp.signals.signal_handler"\ """ ) - assert spans[0]["attributes"]["sentry.op"] == "event.django" + assert spans[0]["attributes"]["sentry.op"] == "function" assert spans[0]["name"] == "django.db.reset_queries" - assert spans[1]["attributes"]["sentry.op"] == "event.django" + assert spans[1]["attributes"]["sentry.op"] == "function" assert spans[1]["name"] == "django.db.close_old_connections" - assert spans[2]["attributes"]["sentry.op"] == "event.django" + assert spans[2]["attributes"]["sentry.op"] == "function" assert spans[2]["name"] == "tests.integrations.django.myapp.signals.signal_handler" @@ -1794,7 +1794,7 @@ def test_span_origin( for span in spans: assert span["attributes"]["sentry.origin"] == "auto.http.django" - if span["attributes"]["sentry.op"] == "event.django": + if span["attributes"]["sentry.op"] == "function": signal_span_found = True assert signal_span_found From b3bac95daba4ccbea8501d613121d8e7ccda69e4 Mon Sep 17 00:00:00 2001 From: Alexander Alderman Webb Date: Mon, 12 Oct 2026 18:26:08 +0200 Subject: [PATCH 2/3] update migration guide --- MIGRATION_GUIDE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MIGRATION_GUIDE.md b/MIGRATION_GUIDE.md index b12227821f..e979cdfbfa 100644 --- a/MIGRATION_GUIDE.md +++ b/MIGRATION_GUIDE.md @@ -42,7 +42,7 @@ Looking to upgrade from Sentry SDK 2.x to 3.x? Here's a comprehensive list of wh 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`, and `view` instead of `view.authenticate`. +- The Django integration now emits `view.render` instead of `view.response.render`, `view` instead of `view.authenticate`, and `function` instead of `event.django`. #### Django From 8db873161e61eee1ac85a65f223f0b9621febebf Mon Sep 17 00:00:00 2001 From: Alexander Alderman Webb Date: Mon, 12 Oct 2026 18:28:57 +0200 Subject: [PATCH 3/3] use op constants where reasonable --- tests/integrations/django/asgi/test_asgi.py | 4 ++-- tests/integrations/django/test_basic.py | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/integrations/django/asgi/test_asgi.py b/tests/integrations/django/asgi/test_asgi.py index cd0933e1a4..056373acf9 100644 --- a/tests/integrations/django/asgi/test_asgi.py +++ b/tests/integrations/django/asgi/test_asgi.py @@ -11,7 +11,7 @@ import sentry_sdk from sentry_sdk import capture_message -from sentry_sdk.consts import SPANDATA +from sentry_sdk.consts import OP, SPANDATA from sentry_sdk.integrations.django import DjangoIntegration from sentry_sdk.integrations.django.asgi import _asgi_middleware_mixin_factory from tests.integrations.django.myapp.asgi import channels_application @@ -271,7 +271,7 @@ async def test_async_middleware_spans( # Filter out signal-receiver spans — their ordering depends on Django # module import order and is not what this middleware test verifies. - spans = [s for s in spans if s["attributes"].get("sentry.op") != "function"] + spans = [s for s in spans if s["attributes"].get("sentry.op") != OP.FUNCTION] assert ( render_span_tree(spans) diff --git a/tests/integrations/django/test_basic.py b/tests/integrations/django/test_basic.py index a8c7aacd9a..b2a0a547a1 100644 --- a/tests/integrations/django/test_basic.py +++ b/tests/integrations/django/test_basic.py @@ -25,7 +25,7 @@ import sentry_sdk from sentry_sdk import capture_exception, capture_message from sentry_sdk._compat import PY310 -from sentry_sdk.consts import SPANDATA +from sentry_sdk.consts import OP, SPANDATA from sentry_sdk.integrations.django import ( DjangoIntegration, DjangoRequestExtractor, @@ -1576,10 +1576,10 @@ def test_signals_spans( """ ) - assert spans[0]["attributes"]["sentry.op"] == "function" + assert spans[0]["attributes"]["sentry.op"] == OP.FUNCTION assert spans[0]["name"] == "django.db.reset_queries" - assert spans[1]["attributes"]["sentry.op"] == "function" + assert spans[1]["attributes"]["sentry.op"] == OP.FUNCTION assert spans[1]["name"] == "django.db.close_old_connections" @@ -1641,13 +1641,13 @@ def test_signals_spans_filtering( """ ) - assert spans[0]["attributes"]["sentry.op"] == "function" + assert spans[0]["attributes"]["sentry.op"] == OP.FUNCTION assert spans[0]["name"] == "django.db.reset_queries" - assert spans[1]["attributes"]["sentry.op"] == "function" + assert spans[1]["attributes"]["sentry.op"] == OP.FUNCTION assert spans[1]["name"] == "django.db.close_old_connections" - assert spans[2]["attributes"]["sentry.op"] == "function" + assert spans[2]["attributes"]["sentry.op"] == OP.FUNCTION assert spans[2]["name"] == "tests.integrations.django.myapp.signals.signal_handler" @@ -1793,7 +1793,7 @@ def test_span_origin( for span in spans: assert span["attributes"]["sentry.origin"] == "auto.http.django" - if span["attributes"]["sentry.op"] == "function": + if span["attributes"]["sentry.op"] == OP.FUNCTION: signal_span_found = True assert signal_span_found