Skip to content
Merged
Changes from all commits
Commits
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
14 changes: 12 additions & 2 deletions sentry_sdk/opentelemetry/sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def should_sample(
)
else:
logger.debug(
f"[Tracing] Ignoring sampled param for non-root span {name}"
f"[Tracing.Sampler] Ignoring sampled param for non-root span {name}"
)

# Check if there is a traces_sampler
Expand Down Expand Up @@ -264,7 +264,7 @@ def should_sample(
# If the sample rate is invalid, drop the span
if not is_valid_sample_rate(sample_rate, source=self.__class__.__name__):
logger.warning(
f"[Tracing] Discarding {name} because of invalid sample rate."
f"[Tracing.Sampler] Discarding {name} because of invalid sample rate."
)
return dropped_result(parent_span_context, attributes)

Expand All @@ -279,13 +279,23 @@ def should_sample(
sampled = sample_rand < Decimal.from_float(sample_rate)

if sampled:
if is_root_span:
logger.debug(
f"[Tracing.Sampler] Sampled #{name} with sample_rate: {sample_rate} and sample_rand: {sample_rand}"
)

return sampled_result(
parent_span_context,
attributes,
sample_rate=sample_rate_to_propagate,
sample_rand=None if sample_rand == parent_sample_rand else sample_rand,
)
else:
if is_root_span:
logger.debug(
f"[Tracing.Sampler] Dropped #{name} with sample_rate: {sample_rate} and sample_rand: {sample_rand}"
)

return dropped_result(
parent_span_context,
attributes,
Expand Down
Loading