Skip to main content

Measurable

Trait Measurable 

Source
pub trait Measurable: Send + Sync {
    // Required method
    fn measure(&self, config: &MetricConfig, now: i64) -> f64;

    // Provided method
    fn type_name(&self) -> Option<&'static str> { ... }
}
Expand description

A measurable quantity that can be registered as a metric.

§Translation notes

Blanket-implements MetricValueProvider.

Required Methods§

Source

fn measure(&self, config: &MetricConfig, now: i64) -> f64

Measure this quantity and return the result as a double.

§Arguments
  • config - The configuration for this metric
  • now - The POSIX time in milliseconds the measurement is being taken
§Returns

The measured value

Provided Methods§

Source

fn type_name(&self) -> Option<&'static str>

Returns the provider’s type name, as KafkaMetric’s Display reports it, or None for a provider that is a closure.

Java’s KafkaMetric.toString reads the provider’s class name reflectively and omits it for a lambda. Rust has no reflection, so the provider reports it: the default is the implementing type’s std::any::type_name, and the closure adapters answer None.

Implementations on Foreign Types§

Source§

impl<M: Measurable + ?Sized> Measurable for Box<M>

A boxed measurable is a measurable, so Box<dyn Measurable> is a crate::common::metrics::MetricValueProvider too.

Source§

fn measure(&self, config: &MetricConfig, now: i64) -> f64

Source§

fn type_name(&self) -> Option<&'static str>

Implementors§