Skip to content

Commit

Permalink
Merge branch 'master' into szokeasaurusrex/flaky-test
Browse files Browse the repository at this point in the history
  • Loading branch information
szokeasaurusrex authored Jul 22, 2024
2 parents 0399076 + e0d6678 commit 624e743
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
7 changes: 4 additions & 3 deletions sentry_sdk/integrations/django/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ class DjangoIntegration(Integration):

identifier = "django"
origin = f"auto.http.{identifier}"
origin_db = f"auto.db.{identifier}"

transaction_style = ""
middleware_spans = None
Expand Down Expand Up @@ -630,7 +631,7 @@ def execute(self, sql, params=None):
params_list=params,
paramstyle="format",
executemany=False,
span_origin=DjangoIntegration.origin,
span_origin=DjangoIntegration.origin_db,
) as span:
_set_db_data(span, self)
options = (
Expand Down Expand Up @@ -663,7 +664,7 @@ def executemany(self, sql, param_list):
params_list=param_list,
paramstyle="format",
executemany=True,
span_origin=DjangoIntegration.origin,
span_origin=DjangoIntegration.origin_db,
) as span:
_set_db_data(span, self)

Expand All @@ -683,7 +684,7 @@ def connect(self):
with sentry_sdk.start_span(
op=OP.DB,
description="connect",
origin=DjangoIntegration.origin,
origin=DjangoIntegration.origin_db,
) as span:
_set_db_data(span, self)
return real_connect(self)
Expand Down
7 changes: 5 additions & 2 deletions tests/integrations/django/test_db_query_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,10 @@ def test_db_span_origin_execute(sentry_init, client, capture_events):
assert event["contexts"]["trace"]["origin"] == "auto.http.django"

for span in event["spans"]:
assert span["origin"] == "auto.http.django"
if span["op"] == "db":
assert span["origin"] == "auto.db.django"
else:
assert span["origin"] == "auto.http.django"


@pytest.mark.forked
Expand Down Expand Up @@ -520,4 +523,4 @@ def test_db_span_origin_executemany(sentry_init, client, capture_events):
(event,) = events

assert event["contexts"]["trace"]["origin"] == "manual"
assert event["spans"][0]["origin"] == "auto.http.django"
assert event["spans"][0]["origin"] == "auto.db.django"

0 comments on commit 624e743

Please sign in to comment.