Skip to content

Commit 172acaf

Browse files
committed
.
1 parent 8010e46 commit 172acaf

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

sentry_sdk/tracing_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ def _fill_sample_rand(self):
495495

496496
def _sample_rand(self):
497497
# type: () -> Optional[str]
498-
"""Convenience method to get the sample_rand value from the dynamic_sampling_context."""
498+
"""Convenience method to get the sample_rand value from the baggage."""
499499
if self.baggage is None:
500500
return None
501501

tests/test_dsc.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
This is not tested in this file.
99
"""
1010

11-
import random
1211
from unittest import mock
1312

1413
import pytest
@@ -269,14 +268,14 @@ def my_traces_sampler(sampling_context):
269268
),
270269
( # 4 traces_sampler overrides incoming (incoming not sampled)
271270
{
272-
"incoming_sample_rate": 0.9,
271+
"incoming_sample_rate": 0.3,
273272
"incoming_sampled": "false",
274273
"sentry_trace_header_parent_sampled": 0,
275274
"use_local_traces_sampler": True,
276-
"local_traces_sampler_result": 0.5,
275+
"local_traces_sampler_result": 0.25,
277276
"local_traces_sample_rate": 0.7,
278277
},
279-
0.5, # expected_sample_rate
278+
0.25, # expected_sample_rate
280279
"false", # expected_sampled (traces sampler can override parent sampled)
281280
),
282281
( # 5 forwarding incoming (traces_sample_rate not set)
@@ -317,14 +316,14 @@ def my_traces_sampler(sampling_context):
317316
),
318317
( # 8 traces_sampler overrides incoming (traces_sample_rate not set) (incoming not sampled)
319318
{
320-
"incoming_sample_rate": 0.9,
319+
"incoming_sample_rate": 0.3,
321320
"incoming_sampled": "false",
322321
"sentry_trace_header_parent_sampled": 0,
323322
"use_local_traces_sampler": True,
324-
"local_traces_sampler_result": 0.5,
323+
"local_traces_sampler_result": 0.25,
325324
"local_traces_sample_rate": None,
326325
},
327-
0.5, # expected_sample_rate
326+
0.25, # expected_sample_rate
328327
"false", # expected_sampled
329328
),
330329
( # 9 traces_sample_rate overrides incoming (upstream deferred sampling decision)
@@ -405,7 +404,7 @@ def my_traces_sampler(sampling_context):
405404
}
406405

407406
# We continue the incoming trace and start a new transaction
408-
with mock.patch.object(random, "random", return_value=0.2):
407+
with mock.patch("sentry_sdk.tracing_utils.Random.uniform", return_value=0.2):
409408
with sentry_sdk.continue_trace(incoming_http_headers):
410409
with sentry_sdk.start_span(name="foo"):
411410
pass

0 commit comments

Comments
 (0)