Skip to content

Commit fec12ca

Browse files
committed
.
1 parent ad8b75b commit fec12ca

3 files changed

Lines changed: 19 additions & 15 deletions

File tree

sentry_sdk/scope.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1263,7 +1263,9 @@ def start_streamed_span(
12631263

12641264
# This is a child span; take propagation context from the parent span
12651265
with new_scope():
1266-
if is_ignored_span(name, attributes) or isinstance(parent_span, NoOpStreamedSpan):
1266+
if is_ignored_span(name, attributes) or isinstance(
1267+
parent_span, NoOpStreamedSpan
1268+
):
12671269
# TODO[span-first]: emit "ignored" client report
12681270
# also add tests for it
12691271
return NoOpStreamedSpan()

sentry_sdk/traces.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -656,15 +656,14 @@ class NoOpStreamedSpan(StreamedSpan):
656656
"_context_manager_state",
657657
)
658658

659-
def __init__(self, scope: "Optional[sentry_sdk.Scope]" = None, **kwargs: "Any") -> None:
659+
def __init__(
660+
self, scope: "Optional[sentry_sdk.Scope]" = None, **kwargs: "Any"
661+
) -> None:
660662
self.segment = None # type: ignore[assignment]
661663
self._scope = scope # type: ignore[assignment]
662664

663665
def __repr__(self) -> str:
664-
return (
665-
f"<{self.__class__.__name__}("
666-
f"sampled={self.sampled})>"
667-
)
666+
return f"<{self.__class__.__name__}(sampled={self.sampled})>"
668667

669668
def __enter__(self) -> "NoOpStreamedSpan":
670669
if self._scope is None:

tests/tracing/test_span_streaming.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -962,7 +962,9 @@ def test_ignore_spans(
962962
assert span["name"] == name
963963

964964

965-
def test_ignore_spans_basic(sentry_init, capture_envelopes, capture_record_lost_event_calls):
965+
def test_ignore_spans_basic(
966+
sentry_init, capture_envelopes, capture_record_lost_event_calls
967+
):
966968
sentry_init(
967969
traces_sample_rate=1.0,
968970
_experiments={
@@ -993,7 +995,9 @@ def test_ignore_spans_basic(sentry_init, capture_envelopes, capture_record_lost_
993995
assert lost_event_calls[0] == ("ignored", "span", None, 1)
994996

995997

996-
def test_ignore_spans_ignored_segment_drops_whole_tree(sentry_init, capture_envelopes, capture_record_lost_event_calls):
998+
def test_ignore_spans_ignored_segment_drops_whole_tree(
999+
sentry_init, capture_envelopes, capture_record_lost_event_calls
1000+
):
9971001
# Ignored segments should drop the whole span tree.
9981002
sentry_init(
9991003
traces_sample_rate=1.0,
@@ -1048,16 +1052,12 @@ def test_ignore_spans_ignored_segment_drops_whole_tree_explicit_parent_span(
10481052
assert isinstance(ignored_span, NoOpStreamedSpan)
10491053
assert ignored_span.sampled is False
10501054

1051-
span1 = sentry_sdk.traces.start_span(
1052-
name="not ignored 1", parent_span=ignored_span
1053-
)
1055+
span1 = sentry_sdk.traces.start_span(name="not ignored 1", parent_span=ignored_span)
10541056
span1.start()
10551057
assert isinstance(span1, NoOpStreamedSpan)
10561058
assert span1.sampled is False
10571059

1058-
span2 = sentry_sdk.traces.start_span(
1059-
name="not ignored 2", parent_span=ignored_span
1060-
)
1060+
span2 = sentry_sdk.traces.start_span(name="not ignored 2", parent_span=ignored_span)
10611061
span2.start()
10621062
assert isinstance(span2, NoOpStreamedSpan)
10631063
assert span2.sampled is False
@@ -1077,7 +1077,9 @@ def test_ignore_spans_ignored_segment_drops_whole_tree_explicit_parent_span(
10771077
assert lost_event_call == ("ignored", "span", None, 1)
10781078

10791079

1080-
def test_ignore_spans_set_ignored_child_span_as_parent(sentry_init, capture_envelopes, capture_record_lost_event_calls):
1080+
def test_ignore_spans_set_ignored_child_span_as_parent(
1081+
sentry_init, capture_envelopes, capture_record_lost_event_calls
1082+
):
10811083
# Ignored non-segment spans should NOT drop the whole subtree under them.
10821084
sentry_init(
10831085
traces_sample_rate=1.0,
@@ -1174,6 +1176,7 @@ def test_ignore_spans_set_ignored_child_span_as_parent_explicit_parent_span(
11741176
for lost_event_call in lost_event_calls:
11751177
assert lost_event_call == ("ignored", "span", None, 1)
11761178

1179+
11771180
def test_ignore_spans_reparenting(sentry_init, capture_envelopes):
11781181
sentry_init(
11791182
traces_sample_rate=1.0,

0 commit comments

Comments
 (0)