Skip to content

Commit 624e743

Browse files
Merge branch 'master' into szokeasaurusrex/flaky-test
2 parents 0399076 + e0d6678 commit 624e743

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

sentry_sdk/integrations/django/__init__.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ class DjangoIntegration(Integration):
116116

117117
identifier = "django"
118118
origin = f"auto.http.{identifier}"
119+
origin_db = f"auto.db.{identifier}"
119120

120121
transaction_style = ""
121122
middleware_spans = None
@@ -630,7 +631,7 @@ def execute(self, sql, params=None):
630631
params_list=params,
631632
paramstyle="format",
632633
executemany=False,
633-
span_origin=DjangoIntegration.origin,
634+
span_origin=DjangoIntegration.origin_db,
634635
) as span:
635636
_set_db_data(span, self)
636637
options = (
@@ -663,7 +664,7 @@ def executemany(self, sql, param_list):
663664
params_list=param_list,
664665
paramstyle="format",
665666
executemany=True,
666-
span_origin=DjangoIntegration.origin,
667+
span_origin=DjangoIntegration.origin_db,
667668
) as span:
668669
_set_db_data(span, self)
669670

@@ -683,7 +684,7 @@ def connect(self):
683684
with sentry_sdk.start_span(
684685
op=OP.DB,
685686
description="connect",
686-
origin=DjangoIntegration.origin,
687+
origin=DjangoIntegration.origin_db,
687688
) as span:
688689
_set_db_data(span, self)
689690
return real_connect(self)

tests/integrations/django/test_db_query_data.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,10 @@ def test_db_span_origin_execute(sentry_init, client, capture_events):
481481
assert event["contexts"]["trace"]["origin"] == "auto.http.django"
482482

483483
for span in event["spans"]:
484-
assert span["origin"] == "auto.http.django"
484+
if span["op"] == "db":
485+
assert span["origin"] == "auto.db.django"
486+
else:
487+
assert span["origin"] == "auto.http.django"
485488

486489

487490
@pytest.mark.forked
@@ -520,4 +523,4 @@ def test_db_span_origin_executemany(sentry_init, client, capture_events):
520523
(event,) = events
521524

522525
assert event["contexts"]["trace"]["origin"] == "manual"
523-
assert event["spans"][0]["origin"] == "auto.http.django"
526+
assert event["spans"][0]["origin"] == "auto.db.django"

0 commit comments

Comments
 (0)