Skip to content

Commit 3a16ef6

Browse files
chore: Replace deprecated event.django op with function (#7960)
1 parent 888b3d3 commit 3a16ef6

4 files changed

Lines changed: 16 additions & 16 deletions

File tree

‎MIGRATION_GUIDE.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Looking to upgrade from Sentry SDK 2.x to 3.x? Here's a comprehensive list of wh
4242
Span ops are now a smaller, framework-neutral set.
4343

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`.
45-
- The Django integration now emits `view.render` instead of `view.response.render`, and `view` instead of `view.authenticate`.
45+
- The Django integration now emits `view.render` instead of `view.response.render`, `view` instead of `view.authenticate`, and `function` instead of `event.django`.
4646

4747
#### Django
4848

‎sentry_sdk/integrations/django/signals_handlers.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def wrapper(*args: "Any", **kwargs: "Any") -> "Any":
6969
with sentry_sdk.start_span(
7070
name=signal_name,
7171
attributes={
72-
"sentry.op": OP.EVENT_DJANGO,
72+
"sentry.op": OP.FUNCTION,
7373
"sentry.origin": DjangoIntegration.origin,
7474
SPANDATA.CODE_FUNCTION_NAME: signal_name,
7575
},

‎tests/integrations/django/asgi/test_asgi.py‎

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

1212
import sentry_sdk
1313
from sentry_sdk import capture_message
14-
from sentry_sdk.consts import SPANDATA
14+
from sentry_sdk.consts import OP, SPANDATA
1515
from sentry_sdk.integrations.django import DjangoIntegration
1616
from sentry_sdk.integrations.django.asgi import _asgi_middleware_mixin_factory
1717
from tests.integrations.django.myapp.asgi import channels_application
@@ -271,7 +271,7 @@ async def test_async_middleware_spans(
271271

272272
# Filter out signal-receiver spans — their ordering depends on Django
273273
# module import order and is not what this middleware test verifies.
274-
spans = [s for s in spans if s["attributes"].get("sentry.op") != "event.django"]
274+
spans = [s for s in spans if s["attributes"].get("sentry.op") != OP.FUNCTION]
275275

276276
assert (
277277
render_span_tree(spans)

‎tests/integrations/django/test_basic.py‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import sentry_sdk
2626
from sentry_sdk import capture_exception, capture_message
2727
from sentry_sdk._compat import PY310
28-
from sentry_sdk.consts import SPANDATA
28+
from sentry_sdk.consts import OP, SPANDATA
2929
from sentry_sdk.integrations.django import (
3030
DjangoIntegration,
3131
DjangoRequestExtractor,
@@ -1571,15 +1571,15 @@ def test_signals_spans(
15711571
render_span_tree(spans)
15721572
== """\
15731573
- sentry.op="http.server": name="/message"
1574-
- sentry.op="event.django": name="django.db.reset_queries"
1575-
- sentry.op="event.django": name="django.db.close_old_connections"\
1574+
- sentry.op="function": name="django.db.reset_queries"
1575+
- sentry.op="function": name="django.db.close_old_connections"\
15761576
"""
15771577
)
15781578

1579-
assert spans[0]["attributes"]["sentry.op"] == "event.django"
1579+
assert spans[0]["attributes"]["sentry.op"] == OP.FUNCTION
15801580
assert spans[0]["name"] == "django.db.reset_queries"
15811581

1582-
assert spans[1]["attributes"]["sentry.op"] == "event.django"
1582+
assert spans[1]["attributes"]["sentry.op"] == OP.FUNCTION
15831583
assert spans[1]["name"] == "django.db.close_old_connections"
15841584

15851585

@@ -1635,19 +1635,19 @@ def test_signals_spans_filtering(
16351635
render_span_tree(spans)
16361636
== """\
16371637
- sentry.op="http.server": name="/send-myapp-custom-signal"
1638-
- sentry.op="event.django": name="django.db.reset_queries"
1639-
- sentry.op="event.django": name="django.db.close_old_connections"
1640-
- sentry.op="event.django": name="tests.integrations.django.myapp.signals.signal_handler"\
1638+
- sentry.op="function": name="django.db.reset_queries"
1639+
- sentry.op="function": name="django.db.close_old_connections"
1640+
- sentry.op="function": name="tests.integrations.django.myapp.signals.signal_handler"\
16411641
"""
16421642
)
16431643

1644-
assert spans[0]["attributes"]["sentry.op"] == "event.django"
1644+
assert spans[0]["attributes"]["sentry.op"] == OP.FUNCTION
16451645
assert spans[0]["name"] == "django.db.reset_queries"
16461646

1647-
assert spans[1]["attributes"]["sentry.op"] == "event.django"
1647+
assert spans[1]["attributes"]["sentry.op"] == OP.FUNCTION
16481648
assert spans[1]["name"] == "django.db.close_old_connections"
16491649

1650-
assert spans[2]["attributes"]["sentry.op"] == "event.django"
1650+
assert spans[2]["attributes"]["sentry.op"] == OP.FUNCTION
16511651
assert spans[2]["name"] == "tests.integrations.django.myapp.signals.signal_handler"
16521652

16531653

@@ -1793,7 +1793,7 @@ def test_span_origin(
17931793

17941794
for span in spans:
17951795
assert span["attributes"]["sentry.origin"] == "auto.http.django"
1796-
if span["attributes"]["sentry.op"] == "event.django":
1796+
if span["attributes"]["sentry.op"] == OP.FUNCTION:
17971797
signal_span_found = True
17981798

17991799
assert signal_span_found

0 commit comments

Comments
 (0)