Skip to content

Conversation

@alexander-alderman-webb
Copy link
Contributor

@alexander-alderman-webbalexander-alderman-webb commented Nov 18, 2025

Description

Create spans for SQL rollbacks issued when Django calls rollback() on a PEP-249 database connection.

Patch the BaseDatabaseWrapper._rollback method, the same method in which debug statements were added in django/django@798e38c.

Rollback spans are generated for transaction.atomic blocks and for manual transaction.rollback() calls when auto-commit is disabled. Tests cover both cases, for SQLite and PostgreSQL, respectively.

Screenshot 2025-11-21 at 11 12 23

Trying for yourself

Refer to #5100 (comment).

Issues

Reminders

@alexander-alderman-webbalexander-alderman-webb changed the title feat(django): Instrument database commitsfeat(django): Instrument database rollbacksNov 18, 2025
@codecov
Copy link

codecovbot commented Nov 18, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.23%. Comparing base (e068db6) to head (947ac41).
⚠️ Report is 1 commits behind head on master.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@ Coverage Diff @@## master #5115 +/- ## ========================================== - Coverage 83.95% 80.23% -3.72%  ========================================== Files 180 180 Lines 18212 18222 +10 Branches 3234 3235 +1 ========================================== - Hits 15289 14620 -669 - Misses 1931 2695 +764 + Partials 992 907 -85 
Files with missing linesCoverage Δ
sentry_sdk/consts.py99.41% <100.00%> (+<0.01%)⬆️
sentry_sdk/integrations/django/__init__.py85.20% <100.00%> (+0.34%)⬆️

... and 20 files with indirect coverage changes

@alexander-alderman-webbalexander-alderman-webb marked this pull request as ready for review November 21, 2025 10:27
@alexander-alderman-webbalexander-alderman-webb marked this pull request as ready for review November 24, 2025 13:34
Base automatically changed from webb/django-sql-commit to masterNovember 25, 2025 08:10
@alexander-alderman-webbalexander-alderman-webb merged commit 5de66e2 into masterNov 25, 2025
144 of 146 checks passed
@alexander-alderman-webbalexander-alderman-webb deleted the webb/django-sql-rollback branch November 25, 2025 08:31
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@alexander-alderman-webb@sentrivana