Skip to content

Commit 9deee09

Browse files
committed
rename and wip
1 parent 6012909 commit 9deee09

File tree

5 files changed

+52
-53
lines changed

5 files changed

+52
-53
lines changed

sentry_sdk/api.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ def flush(
341341

342342
def start_span(
343343
*,
344-
segment_span=None,
344+
root_span=None,
345345
custom_sampling_context=None,
346346
**kwargs, # type: Any
347347
):
@@ -351,12 +351,11 @@ def start_span(
351351
"""
352352
# TODO: Consider adding type hints to the method signature.
353353
return get_current_scope().start_span(
354-
segment_span, custom_sampling_context, **kwargs
354+
root_span, custom_sampling_context, **kwargs
355355
)
356356

357357

358358
def start_transaction(
359-
*,
360359
transaction=None, # type: Optional[Span]
361360
custom_sampling_context=None, # type: Optional[SamplingContext]
362361
**kwargs, # type: Unpack[TransactionKwargs]
@@ -396,7 +395,7 @@ def start_transaction(
396395
available arguments.
397396
"""
398397
return get_current_scope().start_span(
399-
segment_span=transaction,
398+
root_span=transaction,
400399
custom_sampling_context=custom_sampling_context,
401400
**kwargs,
402401
)

sentry_sdk/integrations/opentelemetry/potel_span_processor.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def on_end(self, span):
5353
self._children_spans[span.parent.span_id].append(span)
5454
else:
5555
# if have a root span ending, we build a transaction and send it
56-
self._flush_segment_span(span)
56+
self._flush_root_span(span)
5757

5858
# TODO-neel-potel not sure we need a clear like JS
5959
def shutdown(self):
@@ -66,9 +66,9 @@ def force_flush(self, timeout_millis=30000):
6666
# type: (int) -> bool
6767
return True
6868

69-
def _flush_segment_span(self, span):
69+
def _flush_root_span(self, span):
7070
# type: (ReadableSpan) -> None
71-
transaction_event = self._segment_span_to_transaction_event(span)
71+
transaction_event = self._root_span_to_transaction_event(span)
7272
if not transaction_event:
7373
return
7474

@@ -103,7 +103,7 @@ def _collect_children(self, span):
103103

104104
# we construct the event from scratch here
105105
# and not use the current Transaction class for easier refactoring
106-
def _segment_span_to_transaction_event(self, span):
106+
def _root_span_to_transaction_event(self, span):
107107
# type: (ReadableSpan) -> Optional[Event]
108108
if not span.context:
109109
return None

sentry_sdk/integrations/wsgi.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def __call__(self, environ, start_response):
9393
)
9494
)
9595

96-
segment_span = continue_trace(
96+
root_span = continue_trace(
9797
environ,
9898
op=OP.HTTP_SERVER,
9999
name="generic WSGI request",
@@ -102,13 +102,13 @@ def __call__(self, environ, start_response):
102102
)
103103

104104
with sentry_sdk.start_transaction(
105-
segment_span, custom_sampling_context={"wsgi_environ": environ}
105+
root_span, custom_sampling_context={"wsgi_environ": environ}
106106
):
107107
try:
108108
response = self.app(
109109
environ,
110110
partial(
111-
_sentry_start_response, start_response, segment_span
111+
_sentry_start_response, start_response, root_span
112112
),
113113
)
114114
except BaseException:

sentry_sdk/scope.py

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ class Scope(object):
165165
"_level",
166166
"_name",
167167
"_fingerprint",
168-
"_segment_span_name",
169-
"_segment_span_info",
168+
"_root_span_name",
169+
"_root_span_info",
170170
"_user",
171171
"_tags",
172172
"_contexts",
@@ -218,8 +218,8 @@ def __copy__(self):
218218
rv._level = self._level
219219
rv._name = self._name
220220
rv._fingerprint = self._fingerprint
221-
rv._segment_span_name = self._segment_span_name
222-
rv._segment_span_info = dict(self._segment_span_info)
221+
rv._root_span_name = self._root_span_name
222+
rv._root_span_info = dict(self._root_span_info)
223223
rv._user = self._user
224224

225225
rv._tags = dict(self._tags)
@@ -669,8 +669,8 @@ def clear(self):
669669
"""Clears the entire scope."""
670670
self._level = None # type: Optional[LogLevelStr]
671671
self._fingerprint = None # type: Optional[List[str]]
672-
self._segment_span_name = None # type: Optional[str]
673-
self._segment_span_info = {} # type: MutableMapping[str, str]
672+
self._root_span_name = None # type: Optional[str]
673+
self._root_span_info = {} # type: MutableMapping[str, str]
674674
self._user = None # type: Optional[Dict[str, Any]]
675675

676676
self._tags = {} # type: Dict[str, Any]
@@ -715,49 +715,49 @@ def transaction(self):
715715
Return the transaction in the scope, if any.
716716
717717
.. deprecated:: 3.0.0
718-
This function is deprecated and will be removed in a future release. Use Scope.segment_span instead.
718+
This function is deprecated and will be removed in a future release. Use Scope.root_span instead.
719719
"""
720720

721721
logger.warning(
722-
"Deprecated: use Scope.segment_span instead. This will be removed in the future."
722+
"Deprecated: use Scope.root_span instead. This will be removed in the future."
723723
)
724724

725-
return self.segment_span
725+
return self.root_span
726726

727727
@property
728-
def segment_span(self):
728+
def root_span(self):
729729
"""Return the root span in the scope, if any."""
730730
# there is no span/transaction on the scope
731731
if self._span is None:
732732
return None
733733

734734
# there is an orphan span on the scope
735-
if self._span.segment_span is None:
735+
if self._span.root_span is None:
736736
return None
737737

738738
# there is either a root span (which is its own containing
739739
# root span) or a non-orphan span on the scope
740-
return self._span.segment_span
740+
return self._span.root_span
741741

742742
def set_transaction_name(self, name, source=None):
743743
# type: (str, Optional[str]) -> None
744744
"""
745745
Set the transaction name and optionally the transaction source.
746746
747747
.. deprecated:: 3.0.0
748-
This function is deprecated and will be removed in a future release. Use Scope.set_segment_span_name instead.
748+
This function is deprecated and will be removed in a future release. Use Scope.set_root_span_name instead.
749749
"""
750-
self.set_segment_span_name(name, source)
750+
self.set_root_span_name(name, source)
751751

752-
def set_segment_span_name(self, name, source=None):
752+
def set_root_span_name(self, name, source=None):
753753
"""Set the root span name and optionally the source."""
754-
self._segment_span_name = name
755-
if self._span and self._span.segment_span:
756-
self._span.segment_span.name = name
754+
self._root_span_name = name
755+
if self._span and self._span.root_span:
756+
self._span.root_span.name = name
757757
if source:
758-
self._span.segment_span.source = source
758+
self._span.root_span.source = source
759759
if source:
760-
self._segment_span_info["source"] = source
760+
self._root_span_info["source"] = source
761761

762762
@_attr_setter
763763
def user(self, value):
@@ -789,9 +789,9 @@ def span(self, span):
789789
return
790790
if span.is_segment:
791791
if span.name:
792-
self._segment_span_name = span.name
792+
self._root_span_name = span.name
793793
if span.source:
794-
self._segment_span_info["source"] = span.source
794+
self._root_span_info["source"] = span.source
795795

796796
@property
797797
def profile(self):
@@ -1016,7 +1016,7 @@ def start_transaction(
10161016

10171017
return span
10181018

1019-
def start_span(self, segment_span=None, custom_sampling_context=None, **kwargs):
1019+
def start_span(self, root_span=None, custom_sampling_context=None, **kwargs):
10201020
# type: (Optional[Span], Optional[SamplingContext], Any) -> Span
10211021
"""
10221022
Start a span whose parent is the currently active span or transaction, if any.
@@ -1028,8 +1028,8 @@ def start_span(self, segment_span=None, custom_sampling_context=None, **kwargs):
10281028
For supported `**kwargs` see :py:class:`sentry_sdk.tracing.Span`.
10291029
"""
10301030
kwargs.setdefault("scope", self)
1031-
if segment_span:
1032-
return segment_span
1031+
if root_span:
1032+
return root_span
10331033

10341034
span = self.span or self.get_isolation_scope().span
10351035

@@ -1073,15 +1073,15 @@ def continue_trace(
10731073
"""
10741074
self.generate_propagation_context(environ_or_headers)
10751075

1076-
segment_span = Span.continue_from_headers(
1076+
root_span = Span.continue_from_headers(
10771077
normalize_incoming_data(environ_or_headers),
10781078
op=op,
10791079
origin=origin,
10801080
name=name,
10811081
source=source,
10821082
)
10831083

1084-
return segment_span
1084+
return root_span
10851085

10861086
def capture_event(self, event, hint=None, scope=None, **scope_kwargs):
10871087
# type: (Event, Optional[Hint], Optional[Scope], Any) -> Optional[str]
@@ -1276,18 +1276,18 @@ def _apply_user_to_event(self, event, hint, options):
12761276
if event.get("user") is None and self._user is not None:
12771277
event["user"] = self._user
12781278

1279-
def _apply_segment_span_name_to_event(self, event, hint, options):
1279+
def _apply_root_span_name_to_event(self, event, hint, options):
12801280
# type: (Event, Hint, Optional[Dict[str, Any]]) -> None
1281-
if event.get("transaction") is None and self._segment_span_name is not None:
1282-
event["transaction"] = self._segment_span_name
1281+
if event.get("transaction") is None and self._root_span_name is not None:
1282+
event["transaction"] = self._root_span_name
12831283

1284-
def _apply_segment_span_info_to_event(self, event, hint, options):
1284+
def _apply_root_span_info_to_event(self, event, hint, options):
12851285
# type: (Event, Hint, Optional[Dict[str, Any]]) -> None
12861286
if (
12871287
event.get("transaction_info") is None
1288-
and self._segment_span_info is not None
1288+
and self._root_span_info is not None
12891289
):
1290-
event["transaction_info"] = self._segment_span_info
1290+
event["transaction_info"] = self._root_span_info
12911291

12921292
def _apply_fingerprint_to_event(self, event, hint, options):
12931293
# type: (Event, Hint, Optional[Dict[str, Any]]) -> None
@@ -1409,8 +1409,8 @@ def apply_to_event(
14091409
self._apply_level_to_event(event, hint, options)
14101410
self._apply_fingerprint_to_event(event, hint, options)
14111411
self._apply_user_to_event(event, hint, options)
1412-
self._apply_segment_span_name_to_event(event, hint, options)
1413-
self._apply_segment_span_info_to_event(event, hint, options)
1412+
self._apply_root_span_name_to_event(event, hint, options)
1413+
self._apply_root_span_info_to_event(event, hint, options)
14141414
self._apply_tags_to_event(event, hint, options)
14151415
self._apply_extra_to_event(event, hint, options)
14161416

@@ -1434,10 +1434,10 @@ def update_from_scope(self, scope):
14341434
self._level = scope._level
14351435
if scope._fingerprint is not None:
14361436
self._fingerprint = scope._fingerprint
1437-
if scope._segment_span_name is not None:
1438-
self._segment_span_name = scope._segment_span_name
1439-
if scope._segment_span_info is not None:
1440-
self._segment_span_info.update(scope._segment_span_info)
1437+
if scope._root_span_name is not None:
1438+
self._root_span_name = scope._root_span_name
1439+
if scope._root_span_info is not None:
1440+
self._root_span_info.update(scope._root_span_info)
14411441
if scope._user is not None:
14421442
self._user = scope._user
14431443
if scope._tags:

sentry_sdk/tracing.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1253,7 +1253,7 @@ def origin(self, value):
12531253
self._otel_span.set_attribute(SentrySpanAttribute.ORIGIN, value)
12541254

12551255
@property
1256-
def segment_span(self):
1256+
def root_span(self):
12571257
if isinstance(self._otel_span, otel_trace.NonRecordingSpan):
12581258
return None
12591259

@@ -1285,7 +1285,7 @@ def containing_transaction(self):
12851285
"""
12861286

12871287
logger.warning("Deprecated: This will be removed in the future.")
1288-
return self.segment_span
1288+
return self.root_span
12891289

12901290
@containing_transaction.setter
12911291
def containing_transaction(self, value):
@@ -1294,7 +1294,7 @@ def containing_transaction(self, value):
12941294
Set this span's transaction.
12951295
12961296
.. deprecated:: 3.0.0
1297-
Use :func:`segment_span` instead.
1297+
Use :func:`root_span` instead.
12981298
"""
12991299
pass
13001300

0 commit comments

Comments
 (0)