Skip to main content

KafkaMetric

Struct KafkaMetric 

Source
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

Source

pub fn config(&self) -> Arc<MetricConfig>

Get the configuration of this metric.

§Returns

Return the config of this metric

Source

pub fn set_config(&self, config: Arc<MetricConfig>)

Set the metric config.

§Arguments
  • config - configuration for this metrics
Source

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.

Source

pub fn measurable(&self) -> Result<&dyn Measurable, Error>

Get the underlying metrics provider.

§Returns

Return the metric provider

§Errors
  • Error::is_local_illegal_state_error if the underlying metric is not a Measurable.

Trait Implementations§

Source§

impl Debug for KafkaMetric

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for KafkaMetric

Source§

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.

Source§

impl Metric for KafkaMetric

Source§

fn metric_name(&self) -> &MetricName

Returns a name for this metric.
Source§

fn metric_value(&self) -> MetricValue

Returns the value of the metric, which may be measurable or a non-measurable gauge.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V