Skip to content

Commit

Permalink
Merge pull request #25 from amirjang/master
Browse files Browse the repository at this point in the history
Issue in sampled_count function
  • Loading branch information
markstory authored Mar 31, 2021
2 parents 4b9e303 + 810e5e2 commit 6b15dd2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,10 @@ impl Client {
/// client.sampled_count("metric.completed", 4, 0.5);
/// ```
pub fn sampled_count(&self, metric: &str, value: f64, rate: f64) {
if rand::random::<f64>() < rate {
if rand::random::<f64>() >= rate {
return;
}
let data = self.prepare(format!("{}:{}|c", metric, value));
let data = self.prepare(format!("{}:{}|c|@{}", metric, value, rate));
self.send(data);
}

Expand Down Expand Up @@ -310,10 +310,10 @@ impl Pipeline {
/// pipe.sampled_count("metric.completed", 4.0, 0.5);
/// ```
pub fn sampled_count(&mut self, metric: &str, value: f64, rate: f64) {
if rand::random::<f64>() < rate {
if rand::random::<f64>() >= rate {
return;
}
let data = format!("{}:{}|c", metric, value);
let data = format!("{}:{}|c|@{}", metric, value, rate);
self.stats.push_back(data);
}

Expand Down

0 comments on commit 6b15dd2

Please sign in to comment.