Skip to main content

GaugeMetric

Trait GaugeMetric 

Source
pub trait GaugeMetric {
    // Required method
    fn name(&self) -> &'static str;
}
Expand description

A metric for capturing gauges.

Gauge values are an instantaneous measurement of a value determined by the client. They do not change unless changed by the client. Examples include things like load average or how many connections are active.

§Example

use relay_statsd::{metric, GaugeMetric};

struct QueueSize;

impl GaugeMetric for QueueSize {
    fn name(&self) -> &'static str {
        "queue_size"
    }
}

let queue = VecDeque::new();

// a simple gauge value
metric!(gauge(QueueSize) = queue.len() as u64);

// a gauge with tags
metric!(
    gauge(QueueSize) = queue.len() as u64,
    server = "server1",
    host = "host1"
);

// subtract from the gauge
metric!(gauge(QueueSize) -= 1);

// subtract from the gauge and provide tags
metric!(
    gauge(QueueSize) -= 1,
    server = "s1",
    host = "h1"
);

Required Methods§

Source

fn name(&self) -> &'static str

Returns the gauge metric name that will be sent to statsd.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§