Skip to content

Commit ccec6ca

Browse files
committed
fix: Fix broken sampling logic
1 parent 7a8b35d commit ccec6ca

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

sentry_sdk/client.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ def _should_capture(
196196

197197
if (
198198
self.options["sample_rate"] < 1.0
199-
and random.random() >= self.options["sample_rate"]
199+
and random.random() <= self.options["sample_rate"]
200200
):
201201
return False
202202

sentry_sdk/hub.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ def finish_trace(self, span):
436436
if span.sampled is None:
437437
# span.sampled = True -> Span forcibly sampled
438438
sample_rate = self.client.options["traces_sample_rate"]
439-
if sample_rate < 1.0 and random.random() >= sample_rate:
439+
if sample_rate < 1.0 and random.random() <= sample_rate:
440440
return None
441441

442442
return self.capture_event(

0 commit comments

Comments
 (0)