[][src]Attribute Macro game_metrics::instrument

#[instrument]

Examples

use game_metrics::{instrument, Metrics};

#[instrument]
fn scoped() {
    let do_stuff = 1 + 1;
}

#[instrument(name = "test")]
fn named() {
   let do_stuff = 1 + 1;
}

let metrics = Metrics::new(1);

(0..1000).for_each(|_| scoped());
(0..1000).for_each(|_| named());

let mut count = 0;

metrics.flush();
metrics.for_each_histogram(|span_name, h| {
    println!("{}", span_name);
    assert!(h.mean() > 0.0);
    count += 1;
});
assert_eq!(count, 2);