Skip to main content

Stat

Trait Stat 

Source
pub trait Stat: Send + Sync {
    // Required method
    fn record(&self, config: &MetricConfig, value: f64, time_ms: i64);
}
Expand description

A Stat is a quantity such as average, max, etc that is computed off the stream of updates to a sensor.

record takes &self: the simple cumulative stats use interior mutability (atomics) so that recording is lock-free, which is the minimal Rust equivalent of Java guarding the stat field with the sensor’s synchronized.

Required Methods§

Source

fn record(&self, config: &MetricConfig, value: f64, time_ms: i64)

Record the given value.

  • config - The configuration to use for this metric
  • value - The value to record
  • time_ms - The POSIX time in milliseconds this value occurred

Implementors§