pub struct KafkaMetric { /* private fields */ }Expand description
A metric tracked by the registry. Holds a MetricName, a (mutable)
MetricConfig and a MetricValueProvider.
In Java the config field is volatile and metricValue/measurableValue
read under a per-metric lock to make the stat read consistent with sensor
records. Because our simple stats are themselves lock-free (atomic), the
value read needs no extra lock; we still guard config with a Mutex so the
config(new) setter is observed atomically, matching Java’s synchronized
setter + volatile read.
Implementations§
Source§impl KafkaMetric
impl KafkaMetric
Sourcepub fn config(&self) -> Arc<MetricConfig>
pub fn config(&self) -> Arc<MetricConfig>
Sourcepub fn set_config(&self, config: Arc<MetricConfig>)
pub fn set_config(&self, config: Arc<MetricConfig>)
Sourcepub fn is_measurable(&self) -> bool
pub fn is_measurable(&self) -> bool
Determine if the metric value provider is of type Measurable.
§Returns
true if the metric value provider is of type Measurable, false otherwise.
Sourcepub fn measurable(&self) -> Result<&dyn Measurable, Error>
pub fn measurable(&self) -> Result<&dyn Measurable, Error>
Trait Implementations§
Source§impl Debug for KafkaMetric
impl Debug for KafkaMetric
Source§impl Display for KafkaMetric
impl Display for KafkaMetric
Source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Returns a human-readable representation of this metric.
The metric value provider is represented by its type name rather than its
own state, to avoid dumping internal stat state (e.g. SampledStat’s
samples) into logs, which could be verbose and is rarely useful for
identifying which metric changed. A closure provider (Java’s lambda or
anonymous class) is omitted.
Java’s toString() names the provider’s Java class
(org.apache.kafka.common.metrics.stats.Avg); the Rust type name is the
Rust type path std::any::type_name reports for the provider.