Skip to content

Commit 78002b7

Browse files
committed
test(django): Delete test_query_source_enabled
It is a strict subset of test_query_source: same view, same db_query_source_threshold_ms, and a subset of its assertions. Its only distinct contribution was pinning that query source attributes are attached when enable_db_query_source is left at its default, so test_query_source now relies on the default rather than setting it explicitly, keeping that pin.
1 parent da81a84 commit 78002b7

1 file changed

Lines changed: 2 additions & 78 deletions

File tree

tests/integrations/django/test_db_query_data.py

Lines changed: 2 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -103,83 +103,6 @@ def test_query_source_disabled(
103103
raise AssertionError("No db span found")
104104

105105

106-
@pytest.mark.forked
107-
@pytest_mark_django_db_decorator(transaction=True)
108-
@pytest.mark.parametrize("enable_db_query_source", [None, True])
109-
@pytest.mark.parametrize("span_streaming", [True, False])
110-
def test_query_source_enabled(
111-
sentry_init,
112-
client,
113-
capture_events,
114-
capture_items,
115-
enable_db_query_source,
116-
span_streaming,
117-
):
118-
sentry_options = {
119-
"integrations": [DjangoIntegration()],
120-
"send_default_pii": True,
121-
"traces_sample_rate": 1.0,
122-
"db_query_source_threshold_ms": 0,
123-
"trace_lifecycle": "stream" if span_streaming else "static",
124-
}
125-
126-
if enable_db_query_source is not None:
127-
sentry_options["enable_db_query_source"] = enable_db_query_source
128-
129-
sentry_init(**sentry_options)
130-
131-
if "postgres" not in connections:
132-
pytest.skip("postgres tests disabled")
133-
134-
# trigger Django to open a new connection by marking the existing one as None.
135-
connections["postgres"].connection = None
136-
137-
if span_streaming:
138-
items = capture_items("span")
139-
140-
_, status, _ = unpack_werkzeug_response(
141-
client.get(reverse("postgres_select_orm"))
142-
)
143-
assert status == "200 OK"
144-
145-
sentry_sdk.flush()
146-
spans = [item.payload for item in items]
147-
148-
for span in spans:
149-
if span["attributes"].get("sentry.op") == "db" and "auth_user" in span.get(
150-
"name"
151-
):
152-
attributes = span.get("attributes", {})
153-
154-
assert SPANDATA.CODE_LINE_NUMBER in attributes
155-
assert SPANDATA.CODE_NAMESPACE in attributes
156-
assert SPANDATA.CODE_FILE_PATH in attributes
157-
assert SPANDATA.CODE_FUNCTION in attributes
158-
break
159-
else:
160-
raise AssertionError("No db span found")
161-
else:
162-
events = capture_events()
163-
164-
_, status, _ = unpack_werkzeug_response(
165-
client.get(reverse("postgres_select_orm"))
166-
)
167-
assert status == "200 OK"
168-
169-
(event,) = events
170-
for span in event["spans"]:
171-
if span.get("op") == "db" and "auth_user" in span.get("description"):
172-
data = span.get("data", {})
173-
174-
assert SPANDATA.CODE_LINENO in data
175-
assert SPANDATA.CODE_NAMESPACE in data
176-
assert SPANDATA.CODE_FILEPATH in data
177-
assert SPANDATA.CODE_FUNCTION in data
178-
break
179-
else:
180-
raise AssertionError("No db span found")
181-
182-
183106
@pytest.mark.forked
184107
@pytest_mark_django_db_decorator(transaction=True)
185108
@pytest.mark.parametrize("span_streaming", [True, False])
@@ -190,11 +113,12 @@ def test_query_source(
190113
capture_items,
191114
span_streaming,
192115
):
116+
# enable_db_query_source is left at its default (True) on purpose:
117+
# this test pins that query source attributes are attached by default.
193118
sentry_init(
194119
integrations=[DjangoIntegration()],
195120
send_default_pii=True,
196121
traces_sample_rate=1.0,
197-
enable_db_query_source=True,
198122
db_query_source_threshold_ms=0,
199123
trace_lifecycle="stream" if span_streaming else "static",
200124
)

0 commit comments

Comments
 (0)