Skip to content

Commit 475c1c2

Browse files
committed
.
1 parent 04328fb commit 475c1c2

3 files changed

Lines changed: 14 additions & 11 deletions

File tree

sentry_sdk/_span_batcher.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414

1515
class SpanBatcher(Batcher["StreamedSpan"]):
16-
# TODO[span-first]: adjust flush/drop defaults
1716
# MAX_BEFORE_FLUSH should be lower than MAX_BEFORE_DROP, so that there is
1817
# a bit of a buffer for spans that appear between setting the flush event
1918
# and actually flushing the buffer.

sentry_sdk/scope.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1246,9 +1246,8 @@ def start_streamed_span(
12461246

12471247
if is_ignored_span(name, attributes):
12481248
return NoOpStreamedSpan(
1249-
trace_id=propagation_context.trace_id,
1250-
unsampled_reason="ignored",
12511249
scope=self,
1250+
unsampled_reason="ignored",
12521251
)
12531252

12541253
sampled, sample_rate, sample_rand, outcome = make_sampling_decision(
@@ -1258,9 +1257,8 @@ def start_streamed_span(
12581257
)
12591258
if sampled is False:
12601259
return NoOpStreamedSpan(
1261-
trace_id=propagation_context.trace_id,
1262-
unsampled_reason=outcome,
12631260
scope=self,
1261+
unsampled_reason=outcome,
12641262
)
12651263

12661264
if sample_rate is not None:
@@ -1282,11 +1280,13 @@ def start_streamed_span(
12821280

12831281
# This is a child span; take propagation context from the parent span
12841282
with new_scope():
1285-
if is_ignored_span(name, attributes) or isinstance(
1286-
parent_span, NoOpStreamedSpan
1287-
):
1283+
if is_ignored_span(name, attributes):
1284+
return NoOpStreamedSpan(
1285+
unsampled_reason="ignored",
1286+
)
1287+
if isinstance(parent_span, NoOpStreamedSpan):
12881288
return NoOpStreamedSpan(
1289-
trace_id=parent_span.trace_id, unsampled_reason="ignored"
1289+
unsampled_reason=parent_span._unsampled_reason,
12901290
)
12911291

12921292
return StreamedSpan(
@@ -1302,7 +1302,7 @@ def start_streamed_span(
13021302

13031303
def _update_sample_rate(self, sample_rate: float) -> None:
13041304
# If we had to adjust the sample rate when setting the sampling decision
1305-
# for the spans, it needs to be updated in the propagation context too
1305+
# for a span, it needs to be updated in the propagation context too
13061306
propagation_context = self.get_active_propagation_context()
13071307
baggage = propagation_context.baggage
13081308

sentry_sdk/traces.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,10 +552,11 @@ def __init__(
552552
scope: "Optional[sentry_sdk.Scope]" = None,
553553
**kwargs: "Any",
554554
) -> None:
555-
self._segment = None # type: ignore[assignment]
556555
self._scope = scope # type: ignore[assignment]
557556
self._unsampled_reason = unsampled_reason
558557

558+
self._segment = None # type: ignore[assignment]
559+
559560
self._start()
560561

561562
def __repr__(self) -> str:
@@ -577,6 +578,9 @@ def name(self) -> str:
577578
def name(self, value: str) -> None:
578579
pass
579580

581+
# XXX[span-first]: These default span_id and trace_id values will be used
582+
# in outgoing requests if a noop span is active. Is that how it should be?
583+
580584
@property
581585
def span_id(self) -> str:
582586
return "0000000000000000"

0 commit comments

Comments
 (0)