Skip to content

Commit

Permalink
#42 Improve API, remove Arc that wraps the closure.
Browse files Browse the repository at this point in the history
  • Loading branch information
mixalturek authored and fralalonde committed Mar 7, 2019
1 parent 5e35e68 commit 4a62271
Show file tree
Hide file tree
Showing 3 changed files with 293 additions and 286 deletions.
5 changes: 2 additions & 3 deletions examples/observer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ extern crate dipstick;

use std::fs::File;
use std::io::{self, BufRead, BufReader};
use std::sync::Arc;
use std::time::{Duration, Instant};

use dipstick::{AtomicBucket, InputScope, MetricValue, Prefixed, ScheduleFlush, Stream};
Expand All @@ -34,8 +33,8 @@ fn main() {
metrics.set_drain(Stream::to_stderr());
let flush_handle = metrics.flush_every(Duration::from_secs(1));

metrics.observe("uptime", Arc::new(move || dur2ms(start_time.elapsed())));
metrics.observe("threads", Arc::new(threads));
metrics.observe("uptime", move || dur2ms(start_time.elapsed()));
metrics.observe("threads", threads);

println!("Press Enter key to exit");
io::stdin().read_line(&mut String::new()).expect("Example, ignored");
Expand Down
2 changes: 1 addition & 1 deletion src/bucket/atomic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ impl InputScope for AtomicBucket {
InputMetric::new(move |value, _labels| scores.update(value))
}

fn observe(&self, name: &str, callback: GaugeCallback) {
fn observe_helper(&self, name: &str, callback: GaugeCallback) {
let gauge = self.gauge(name);

write_lock!(self.inner)
Expand Down

0 comments on commit 4a62271

Please sign in to comment.