Skip to main content

MetricValueProvider

Trait MetricValueProvider 

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

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

Super-interface for Measurable or Gauge that provides metric values.

§Translation notes

It yields a MetricValue.

Required Methods§

Source

fn value(&self, config: &MetricConfig, now: i64) -> MetricValue

Returns the current value associated with this metric.

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

the current metric 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.

Implementors§

Source§

impl<M: Measurable> MetricValueProvider for M

Java’s Measurable.value default: the measured quantity as a double.