[][src]Macro metrics::gauge

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

Update a gauge with a value.

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

Functionally equivalent to calling Recorder::update_gauge.

Examples

use metrics::gauge;

fn update_current_value() {
    gauge!("current_value", -131);
}

Labels can also be passed along:

use metrics::gauge;

fn update_current_value() {
    let value: i64 = -131;
    let creator: String = String::from("jane");
    gauge!("current_value", value, "creator" => creator);
}