Skip to content

Commit da5e47f

Browse files
feat(tracing): Remove containing_transaction
BREAKING CHANGE: Remove `Span.containing_transaction`. Use `Span.root_span` instead. Closes #4253
1 parent f78c49d commit da5e47f

File tree

3 files changed

+9
-26
lines changed

3 files changed

+9
-26
lines changed

sentry_sdk/scope.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -698,21 +698,21 @@ def transaction(self):
698698
return None
699699

700700
# there is an orphan span on the scope
701-
if self._span.containing_transaction is None:
701+
if self._span.root_span is None:
702702
return None
703-
# there is either a transaction (which is its own containing
704-
# transaction) or a non-orphan span on the scope
705-
return self._span.containing_transaction
703+
# there is either a root span (which is its own root
704+
# span) or a non-orphan span on the scope
705+
return self._span.root_span
706706

707707
def set_transaction_name(self, name, source=None):
708708
# type: (str, Optional[str]) -> None
709709
"""Set the transaction name and optionally the transaction source."""
710710
self._transaction = name
711711

712-
if self._span and self._span.containing_transaction:
713-
self._span.containing_transaction.name = name
712+
if self._span and self._span.root_span:
713+
self._span.root_span.name = name
714714
if source:
715-
self._span.containing_transaction.source = source
715+
self._span.root_span.source = source
716716

717717
if source:
718718
self._transaction_info["source"] = source

sentry_sdk/tracing.py

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from datetime import datetime
22
from enum import Enum
33
import json
4-
import warnings
54

65
from opentelemetry import trace as otel_trace, context
76
from opentelemetry.trace import (
@@ -139,7 +138,7 @@ def __repr__(self):
139138
return "<%s>" % self.__class__.__name__
140139

141140
@property
142-
def containing_transaction(self):
141+
def root_span(self):
143142
# type: () -> Optional[Span]
144143
return None
145144

@@ -388,22 +387,6 @@ def origin(self, value):
388387

389388
self.set_attribute(SentrySpanAttribute.ORIGIN, value)
390389

391-
@property
392-
def containing_transaction(self):
393-
# type: () -> Optional[Span]
394-
"""
395-
Get the transaction this span is a child of.
396-
397-
.. deprecated:: 3.0.0
398-
This will be removed in the future. Use :func:`root_span` instead.
399-
"""
400-
warnings.warn(
401-
"Deprecated: This will be removed in the future. Use root_span instead.",
402-
DeprecationWarning,
403-
stacklevel=2,
404-
)
405-
return self.root_span
406-
407390
@property
408391
def root_span(self):
409392
# type: () -> Optional[Span]

tests/integrations/rust_tracing/test_rust_tracing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ def test_on_new_span_without_transaction(sentry_init):
189189
rust_tracing.new_span(RustTracingLevel.Info, 3)
190190
current_span = sentry_sdk.get_current_span()
191191
assert current_span is not None
192-
assert current_span.containing_transaction is None
192+
assert current_span.root_span is None
193193

194194

195195
def test_on_event_exception(sentry_init, capture_events):

0 commit comments

Comments
 (0)