[][src]Macro metrics::gauge

macro_rules! gauge {
    #[proc_macro_hack] => { ... };
}

Updates a gauge.

Gauges represent a single value that can go up or down over time.

Scoped versus unscoped

Metrics can be unscoped or scoped, where the scoping is derived by the current module the call is taking place in. This scope is used as a prefix to the provided metric name.

Example

// A regular, unscoped gauge:
gauge!("some_metric_name", 42.2222);

// A scoped gauge.  This inherits a scope derived by the current module:
gauge!(<"some_metric_name">, 33.3333);

// Specifying labels:
gauge!("some_metric_name", 66.6666, "service" => "http");

// And all combined:
gauge!("some_metric_name", 55.5555, "service" => "http");
gauge!(<"some_metric_name">, 11.1111, "service" => "http");

// And just for an alternative form of passing labels:
let dynamic_val = "woo";
let labels = [("dynamic_key", format!("{}!", dynamic_val))];
gauge!("some_metric_name", 42.42, &labels);