Skip to content

Commit

Permalink
Don't generate a random to choose whether we should sample if samplin…
Browse files Browse the repository at this point in the history
…g is fully disabled (rate = 0.0) (#667)
  • Loading branch information
Ten0 authored Jul 12, 2024
1 parent e828ca2 commit 8a04605
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions sentry-core/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ use std::any::TypeId;
use std::borrow::Cow;
use std::fmt;
use std::panic::RefUnwindSafe;
use std::sync::Arc;
use std::sync::RwLock;
use std::sync::{Arc, RwLock};
use std::time::Duration;

use rand::random;
Expand Down Expand Up @@ -377,6 +376,8 @@ impl Client {
pub fn sample_should_send(&self, rate: f32) -> bool {
if rate >= 1.0 {
true
} else if rate <= 0.0 {
false
} else {
random::<f32>() < rate
}
Expand Down

0 comments on commit 8a04605

Please sign in to comment.