Skip to content

Commit 112c28f

Browse files
authored
Add logger.debug for sampler decisions for root spans (#4355)
1 parent 060b2cf commit 112c28f

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

sentry_sdk/opentelemetry/sampler.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ def should_sample(
234234
)
235235
else:
236236
logger.debug(
237-
f"[Tracing] Ignoring sampled param for non-root span {name}"
237+
f"[Tracing.Sampler] Ignoring sampled param for non-root span {name}"
238238
)
239239

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

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

281281
if sampled:
282+
if is_root_span:
283+
logger.debug(
284+
f"[Tracing.Sampler] Sampled #{name} with sample_rate: {sample_rate} and sample_rand: {sample_rand}"
285+
)
286+
282287
return sampled_result(
283288
parent_span_context,
284289
attributes,
285290
sample_rate=sample_rate_to_propagate,
286291
sample_rand=None if sample_rand == parent_sample_rand else sample_rand,
287292
)
288293
else:
294+
if is_root_span:
295+
logger.debug(
296+
f"[Tracing.Sampler] Dropped #{name} with sample_rate: {sample_rate} and sample_rand: {sample_rand}"
297+
)
298+
289299
return dropped_result(
290300
parent_span_context,
291301
attributes,

0 commit comments

Comments
 (0)