@@ -73,6 +73,15 @@ def test_db_no_autocommit_execute(sentry_init, client, capture_events):
7373 "SENTRY_PYTHON_TEST_POSTGRES_PORT" , "5432"
7474 )
7575
76+ insert_spans = [
77+ span for span in event ["spans" ] if span ["description" ].startswith ("INSERT INTO" )
78+ ]
79+ assert len (insert_spans ) == 1
80+ insert_span = insert_spans [0 ]
81+
82+ # Verify query and commit statements are siblings
83+ assert commit_span ["parent_span_id" ] == insert_span ["parent_span_id" ]
84+
7685
7786@pytest .mark .forked
7887@pytest_mark_django_db_decorator (transaction = True )
@@ -149,6 +158,14 @@ def test_db_no_autocommit_executemany(sentry_init, client, capture_events):
149158 "database"
150159 ) or conn_params .get ("dbname" )
151160
161+ insert_spans = [
162+ span for span in event ["spans" ] if span ["description" ].startswith ("INSERT INTO" )
163+ ]
164+
165+ # Verify queries and commit statements are siblings
166+ for insert_span in insert_spans :
167+ assert commit_span ["parent_span_id" ] == insert_span ["parent_span_id" ]
168+
152169
153170@pytest .mark .forked
154171@pytest_mark_django_db_decorator (transaction = True )
@@ -198,6 +215,15 @@ def test_db_atomic_execute(sentry_init, client, capture_events):
198215 "SENTRY_PYTHON_TEST_POSTGRES_PORT" , "5432"
199216 )
200217
218+ insert_spans = [
219+ span for span in event ["spans" ] if span ["description" ].startswith ("INSERT INTO" )
220+ ]
221+ assert len (insert_spans ) == 1
222+ insert_span = insert_spans [0 ]
223+
224+ # Verify query and commit statements are siblings
225+ assert commit_span ["parent_span_id" ] == insert_span ["parent_span_id" ]
226+
201227
202228@pytest .mark .forked
203229@pytest_mark_django_db_decorator (transaction = True )
@@ -270,3 +296,11 @@ def test_db_atomic_executemany(sentry_init, client, capture_events):
270296 assert commit_span ["data" ].get (SPANDATA .DB_NAME ) == conn_params .get (
271297 "database"
272298 ) or conn_params .get ("dbname" )
299+
300+ insert_spans = [
301+ span for span in event ["spans" ] if span ["description" ].startswith ("INSERT INTO" )
302+ ]
303+
304+ # Verify queries and commit statements are siblings
305+ for insert_span in insert_spans :
306+ assert commit_span ["parent_span_id" ] == insert_span ["parent_span_id" ]
0 commit comments