Skip to content

Commit ccec6ca

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

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

sentry_sdk/client.py

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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)