Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
bdb6501
feat: Set segment name on scope when span is NoOpStreamedSpan
alexander-alderman-webb Aug 11, 2026
e6dcbd5
provide argument
alexander-alderman-webb Aug 11, 2026
9fa191f
.
alexander-alderman-webb Aug 11, 2026
b940d77
gate _attributes access
alexander-alderman-webb Aug 11, 2026
bd0f929
.
alexander-alderman-webb Aug 11, 2026
a675dda
add test
alexander-alderman-webb Aug 11, 2026
00f076c
.
alexander-alderman-webb Aug 11, 2026
3c03d56
feat: Set segment source on scope for NoOpStreamedSpan
alexander-alderman-webb Aug 11, 2026
239fed3
use correct attribute
alexander-alderman-webb Aug 11, 2026
3ab0c75
make mypy happy
alexander-alderman-webb Aug 11, 2026
63e764a
add integration test
alexander-alderman-webb Aug 11, 2026
cf2559f
Merge branch 'webb/set-transaction-on-scope' into webb/set-segment-so…
alexander-alderman-webb Aug 11, 2026
f6df6b6
update test
alexander-alderman-webb Aug 11, 2026
2353ae1
fix test
alexander-alderman-webb Aug 11, 2026
70b1a77
feat: Remove early return for NoOpStreamedSpan in set_transaction_name
alexander-alderman-webb Aug 11, 2026
37d544a
Merge branch 'webb/remove-set-transaction-name-early-return' into web…
alexander-alderman-webb Aug 11, 2026
f4986d9
re-use parent _name field
alexander-alderman-webb Aug 11, 2026
c9981ae
Merge branch 'webb/set-transaction-on-scope' into webb/remove-set-tra…
alexander-alderman-webb Aug 11, 2026
556c404
use _attributes instead of new slot
alexander-alderman-webb Aug 11, 2026
67db007
use super().set_attribute()
alexander-alderman-webb Aug 11, 2026
8101f7f
merge master
alexander-alderman-webb Aug 12, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions sentry_sdk/scope.py
Original file line number Diff line number Diff line change
Expand Up @@ -933,8 +933,13 @@ def streamed_span(self, span: "Optional[StreamedSpan]") -> None:
)
return

if type(span) is NoOpStreamedSpan and span._name is not None:
self._transaction = span.name
if type(span) is NoOpStreamedSpan:
if span._name is not None:
self._transaction = span.name
if span._attributes.get("sentry.segment.name.source"):
self._transaction_info["source"] = str(
span._attributes["sentry.segment.name.source"]
)

@property
def profile(self) -> "Optional[Profile]":
Expand Down Expand Up @@ -1314,6 +1319,7 @@ def start_streamed_span(
if is_ignored_span(name, attributes):
return NoOpStreamedSpan(
name=name,
attributes=attributes,
scope=self,
segment=None,
trace_id=propagation_context.trace_id,
Expand All @@ -1335,6 +1341,7 @@ def start_streamed_span(
if sampled is False or sampled is None:
return NoOpStreamedSpan(
name=name,
attributes=attributes,
scope=self,
segment=None,
trace_id=propagation_context.trace_id,
Expand Down Expand Up @@ -1366,6 +1373,7 @@ def start_streamed_span(
if is_ignored_span(name, attributes):
return NoOpStreamedSpan(
name=name,
attributes=attributes,
segment=parent_span._segment,
trace_id=parent_span.trace_id,
parent_span_id=parent_span.span_id,
Expand All @@ -1376,6 +1384,7 @@ def start_streamed_span(
if isinstance(parent_span, NoOpStreamedSpan):
return NoOpStreamedSpan(
name=name,
attributes=attributes,
segment=parent_span._segment,
trace_id=parent_span.trace_id,
parent_span_id=parent_span.span_id,
Expand Down
17 changes: 15 additions & 2 deletions sentry_sdk/traces.py
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,7 @@ class NoOpStreamedSpan(StreamedSpan):
def __init__(
self,
name: "Optional[str]" = None,
attributes: "Optional[Attributes]" = None,
segment: "Optional[StreamedSpan]" = None,
trace_id: "Optional[str]" = None,
parent_span_id: "Optional[str]" = None,
Expand All @@ -645,6 +646,11 @@ def __init__(
sample_rate: "Optional[float]" = None,
) -> None:
self._name = name # type: ignore[assignment]
self._attributes = {}
if attributes is not None and "sentry.segment.name.source" in attributes:
self.set_attribute(
"sentry.segment.name.source", attributes["sentry.segment.name.source"]
)

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

Expand Down Expand Up @@ -724,10 +730,17 @@ def get_attributes(self) -> "Attributes":
return {}

def set_attribute(self, key: str, value: "AttributeValue") -> None:
pass
if key != "sentry.segment.name.source":
return

super().set_attribute("sentry.segment.name.source", value)

def set_attributes(self, attributes: "Attributes") -> None:
pass
Comment thread
alexander-alderman-webb marked this conversation as resolved.
for key, value in attributes.items():
if key != "sentry.segment.name.source":
continue

self.set_attribute("sentry.segment.name.source", value)

def remove_attribute(self, key: str) -> None:
pass
Expand Down
6 changes: 5 additions & 1 deletion tests/tracing/test_integration_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,17 @@ def test_error_event_linked_without_performance_span_streaming(
sentry_init(traces_sample_rate=None, trace_lifecycle="stream")
items = capture_items("event")

with sentry_sdk.traces.start_span(name="no-op span"):
with sentry_sdk.traces.start_span(
name="no-op span",
attributes={"sentry.segment.name.source": "custom segment source"},
):
sentry_sdk.capture_message("hi")

sentry_sdk.flush()

(event,) = (item.payload for item in items)
assert event["transaction"] == "no-op span"
assert event["transaction_info"] == {"source": "custom segment source"}


@pytest.mark.parametrize("parent_sampled", [True, False, None])
Expand Down
Loading