Skip to content

Commit 556c404

Browse files
use _attributes instead of new slot
2 parents 37d544a + c9981ae commit 556c404

2 files changed

Lines changed: 17 additions & 14 deletions

File tree

sentry_sdk/scope.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -933,10 +933,13 @@ def streamed_span(self, span: "Optional[StreamedSpan]") -> None:
933933
)
934934
return
935935

936-
if type(span) is NoOpStreamedSpan and span._noop_name is not None:
937-
self._transaction = span.name
938-
if span._segment_source is not None:
939-
self._transaction_info["source"] = str(span._segment_source)
936+
if type(span) is NoOpStreamedSpan:
937+
if span._name is not None:
938+
self._transaction = span.name
939+
if span._attributes.get("sentry.segment.name.source"):
940+
self._transaction_info["source"] = str(
941+
span._attributes["sentry.segment.name.source"]
942+
)
940943

941944
@property
942945
def profile(self) -> "Optional[Profile]":

sentry_sdk/traces.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -625,8 +625,6 @@ def _to_json(self) -> "SpanJSON":
625625

626626
class NoOpStreamedSpan(StreamedSpan):
627627
__slots__ = (
628-
"_noop_name",
629-
"_segment_source",
630628
"_sampled",
631629
"_finished",
632630
"_unsampled_reason",
@@ -647,10 +645,12 @@ def __init__(
647645
sample_rand: "Optional[float]" = None,
648646
sample_rate: "Optional[float]" = None,
649647
) -> None:
650-
self._noop_name = name
651-
self._segment_source: "Optional[AttributeValue]" = None
652-
if attributes is not None:
653-
self._segment_source = attributes.get("sentry.segment.name.source")
648+
self._name = name # type: ignore[assignment]
649+
self._attributes = {}
650+
if attributes is not None and "sentry.segment.name.source" in attributes:
651+
self.set_attribute(
652+
"sentry.segment.name.source", attributes["sentry.segment.name.source"]
653+
)
654654

655655
self._span_id: "Optional[str]" = None
656656

@@ -733,14 +733,14 @@ def set_attribute(self, key: str, value: "AttributeValue") -> None:
733733
if key != "sentry.segment.name.source":
734734
return
735735

736-
self._segment_source = value
736+
self.set_attribute("sentry.segment.name.source", value)
737737

738738
def set_attributes(self, attributes: "Attributes") -> None:
739739
for key, value in attributes.items():
740740
if key != "sentry.segment.name.source":
741741
continue
742742

743-
self._segment_source = value
743+
self.set_attribute("sentry.segment.name.source", value)
744744

745745
def remove_attribute(self, key: str) -> None:
746746
pass
@@ -755,11 +755,11 @@ def status(self, status: "Union[SpanStatus, str]") -> None:
755755

756756
@property
757757
def name(self) -> str:
758-
return self._noop_name or ""
758+
return self._name or ""
759759

760760
@name.setter
761761
def name(self, name: str) -> None:
762-
self._noop_name = name
762+
self._name = name
763763

764764
@property
765765
def active(self) -> bool:

0 commit comments

Comments
 (0)