Skip to content

Commit 7b2e9df

Browse files
authored
ref: Add _is_segment() to streaming spans (#5619)
1 parent 2d05f5d commit 7b2e9df

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

sentry_sdk/_span_batcher.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ def _to_transport_format(item: "StreamedSpan") -> "Any":
9191
"span_id": item.span_id,
9292
"name": item._name,
9393
"status": item._status,
94+
"is_segment": item._is_segment(),
9495
"start_timestamp": item._start_timestamp.timestamp(),
9596
}
9697

sentry_sdk/traces.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,9 @@ def start_timestamp(self) -> "Optional[datetime]":
447447
def timestamp(self) -> "Optional[datetime]":
448448
return self._timestamp
449449

450+
def _is_segment(self) -> bool:
451+
return self._segment is self
452+
450453

451454
class NoOpStreamedSpan(StreamedSpan):
452455
__slots__ = (
@@ -533,6 +536,9 @@ def set_attributes(self, attributes: "Attributes") -> None:
533536
def remove_attribute(self, key: str) -> None:
534537
pass
535538

539+
def _is_segment(self) -> bool:
540+
return self._scope is not None
541+
536542
@property
537543
def status(self) -> "str":
538544
return SpanStatus.OK.value

0 commit comments

Comments
 (0)