Skip to main content

DistributionMetric

Trait DistributionMetric 

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

A metric for capturing distributions.

A distribution is often similar to timers. Distributions can be thought of as a more general (not limited to timing things) form of timers.

§Example

use relay_statsd::{metric, DistributionMetric};

struct QueueSize;

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

let queue = VecDeque::new();

// record a distribution value (uses global sample rate)
metric!(distribution(QueueSize) = queue.len() as u64);

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

Required Methods§

Source

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

Returns the distribution 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§