Skip to content

Commit cdd365b

Browse files
committed
sample rand fix
1 parent 5f1ac23 commit cdd365b

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

sentry_sdk/tracing_utils.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1483,6 +1483,8 @@ def make_sampling_decision(
14831483
"""
14841484
Decide whether a span should be sampled.
14851485
1486+
Use traces_sampler if defined, otherwise traces_sample_rate.
1487+
14861488
Returns a tuple with:
14871489
- the sampling decision
14881490
- the effective sample rate
@@ -1496,9 +1498,10 @@ def make_sampling_decision(
14961498

14971499
propagation_context = scope.get_active_propagation_context()
14981500

1501+
sample_rand = None
14991502
if propagation_context.baggage is not None:
15001503
sample_rand = propagation_context.baggage._sample_rand()
1501-
else:
1504+
if sample_rand is None:
15021505
sample_rand = _generate_sample_rand(propagation_context.trace_id)
15031506

15041507
sampling_context = {
@@ -1529,6 +1532,7 @@ def make_sampling_decision(
15291532

15301533
sample_rate = float(sample_rate)
15311534

1535+
# Adjust sample rate if we're under backpressure
15321536
if client.monitor:
15331537
sample_rate /= 2**client.monitor.downsample_factor
15341538

0 commit comments

Comments
 (0)