Skip to content

Commit 6584ce0

Browse files
feat(tracing): Remove containing_transaction (#4255)
BREAKING CHANGE: Remove `Span.containing_transaction`. Use `Span.root_span` instead. Closes #4253 <!-- Describe your PR here --> --- Thank you for contributing to `sentry-python`! Please add tests to validate your changes, and lint your code using `tox -e linters`. Running the test suite on your PR might require maintainer approval.
1 parent cd0c8ff commit 6584ce0

File tree

3 files changed

+9
-26
lines changed

3 files changed

+9
-26
lines changed

sentry_sdk/scope.py

+7-7
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

+1-18
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

@@ -385,22 +384,6 @@ def origin(self, value):
385384

386385
self.set_attribute(SentrySpanAttribute.ORIGIN, value)
387386

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

tests/integrations/rust_tracing/test_rust_tracing.py

+1-1
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)