Skip to content

Commit d333393

Browse files
merge
2 parents 3407867 + 2668f4e commit d333393

File tree

3 files changed

+15
-16
lines changed

3 files changed

+15
-16
lines changed

sentry_sdk/consts.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,9 @@ class INSTRUMENTER:
114114
OTEL = "otel"
115115

116116

117-
class DBOPERATION:
118-
COMMIT = "COMMIT"
119-
ROLLBACK = "ROLLBACK"
117+
class SPANNAME:
118+
DB_COMMIT = "COMMIT"
119+
DB_ROLLBACK = "ROLLBACK"
120120

121121

122122
class SPANDATA:

sentry_sdk/integrations/django/__init__.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from importlib import import_module
66

77
import sentry_sdk
8-
from sentry_sdk.consts import OP, SPANDATA, DBOPERATION
8+
from sentry_sdk.consts import OP, SPANDATA, SPANNAME
99
from sentry_sdk.scope import add_global_event_processor, should_send_default_pii
1010
from sentry_sdk.serializer import add_global_repr_processor, add_repr_sequence_type
1111
from sentry_sdk.tracing import SOURCE_FOR_STYLE, TransactionSource
@@ -132,7 +132,7 @@ def __init__(
132132
middleware_spans=True, # type: bool
133133
signals_spans=True, # type: bool
134134
cache_spans=False, # type: bool
135-
database_transaction_spans=False, # type: bool
135+
db_transaction_spans=False, # type: bool
136136
signals_denylist=None, # type: Optional[list[signals.Signal]]
137137
http_methods_to_capture=DEFAULT_HTTP_METHODS_TO_CAPTURE, # type: tuple[str, ...]
138138
):
@@ -149,7 +149,7 @@ def __init__(
149149
self.signals_denylist = signals_denylist or []
150150

151151
self.cache_spans = cache_spans
152-
self.database_transaction_spans = database_transaction_spans
152+
self.db_transaction_spans = db_transaction_spans
153153

154154
self.http_methods_to_capture = tuple(map(str.upper, http_methods_to_capture))
155155

@@ -694,20 +694,19 @@ def connect(self):
694694
_set_db_data(span, self)
695695
return real_connect(self)
696696

697-
@ensure_integration_enabled(DjangoIntegration, real_commit)
698697
def _commit(self):
699698
# type: (BaseDatabaseWrapper) -> None
700699
integration = sentry_sdk.get_client().get_integration(DjangoIntegration)
701700

702-
if integration is None or not integration.database_transaction_spans:
701+
if integration is None or not integration.db_transaction_spans:
703702
return real_commit(self)
704703

705704
with sentry_sdk.start_span(
706705
op=OP.DB,
707-
name=DBOPERATION.COMMIT,
706+
name=SPANNAME.COMMIT,
708707
origin=DjangoIntegration.origin_db,
709708
) as span:
710-
_set_db_data(span, self, DBOPERATION.COMMIT)
709+
_set_db_data(span, self, SPANNAME.COMMIT)
711710
return real_commit(self)
712711

713712
@ensure_integration_enabled(DjangoIntegration, real_rollback)
@@ -720,10 +719,10 @@ def _rollback(self):
720719

721720
with sentry_sdk.start_span(
722721
op=OP.DB,
723-
name=DBOPERATION.ROLLBACK,
722+
name=SPANNAME.ROLLBACK,
724723
origin=DjangoIntegration.origin_db,
725724
) as span:
726-
_set_db_data(span, self, DBOPERATION.ROLLBACK)
725+
_set_db_data(span, self, SPANNAME.ROLLBACK)
727726
return real_rollback(self)
728727

729728
CursorWrapper.execute = execute

tests/integrations/django/test_db_transactions.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ def test_db_transaction_spans_disabled_atomic(sentry_init, client, capture_event
273273
@pytest_mark_django_db_decorator(transaction=True)
274274
def test_db_no_autocommit_execute(sentry_init, client, capture_events):
275275
sentry_init(
276-
integrations=[DjangoIntegration(database_transaction_spans=True)],
276+
integrations=[DjangoIntegration(db_transaction_spans=True)],
277277
traces_sample_rate=1.0,
278278
)
279279

@@ -331,7 +331,7 @@ def test_db_no_autocommit_execute(sentry_init, client, capture_events):
331331
@pytest_mark_django_db_decorator(transaction=True)
332332
def test_db_no_autocommit_executemany(sentry_init, client, capture_events):
333333
sentry_init(
334-
integrations=[DjangoIntegration(database_transaction_spans=True)],
334+
integrations=[DjangoIntegration(db_transaction_spans=True)],
335335
traces_sample_rate=1.0,
336336
)
337337

@@ -557,7 +557,7 @@ def test_db_no_autocommit_rollback_executemany(sentry_init, client, capture_even
557557
@pytest_mark_django_db_decorator(transaction=True)
558558
def test_db_atomic_execute(sentry_init, client, capture_events):
559559
sentry_init(
560-
integrations=[DjangoIntegration(database_transaction_spans=True)],
560+
integrations=[DjangoIntegration(db_transaction_spans=True)],
561561
traces_sample_rate=1.0,
562562
)
563563

@@ -615,7 +615,7 @@ def test_db_atomic_execute(sentry_init, client, capture_events):
615615
@pytest_mark_django_db_decorator(transaction=True)
616616
def test_db_atomic_executemany(sentry_init, client, capture_events):
617617
sentry_init(
618-
integrations=[DjangoIntegration(database_transaction_spans=True)],
618+
integrations=[DjangoIntegration(db_transaction_spans=True)],
619619
send_default_pii=True,
620620
traces_sample_rate=1.0,
621621
)

0 commit comments

Comments
 (0)