[][src]Macro metrics::counter

macro_rules! counter {
    ($name:expr, $value:expr) => { ... };
    ($name:expr, $value:expr, $($labels:tt)*) => { ... };
}

Increments a counter by a value.

This will register a counter with the given name, if it does not already exist, then increment it by the given value. Optionally, a set of labels, of the form key => value, can be passed to further describe the counter.

Functionally equivalent to calling Recorder::increment_counter.

Examples

use metrics::counter;

fn send_msg() {
    counter!("msg_sent_total", 1);
    // ...
}

Labels can also be optionally provided.

use metrics::counter;

fn do_thing() {
    let count: u64 = 42;
    let user: String = String::from("jane");
    counter!("do_thing", count, "service" => "admin", "user" => user);
}