Skip to main content

SampledStat

Struct SampledStat 

Source
pub struct SampledStat { /* private fields */ }
Expand description

A SampledStat records a single scalar value measured over one or more samples. Each sample is recorded over a configurable window. The window can be defined by number of events or elapsed time (or both, if both are given the window is complete when either the event count or elapsed time criterion is met).

All the samples are combined to produce the measurement. When a window is complete the oldest sample is cleared and recycled to begin recording the next sample.

Implementations§

Source§

impl SampledStat

Source

pub fn new(initial_value: f64, kind: Box<dyn SampledStatKind>) -> Self

Create a SampledStat with the given initial value and per-subclass behaviour.

§Arguments
  • initial_value - the value a sample starts from
  • kind - the subclass behaviour: update and combine

Trait Implementations§

Source§

impl Debug for SampledStat

Source§

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

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

impl Display for SampledStat

Source§

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

Java’s SampledStat.toString(), which Avg, Max, Min, WindowedCount and WindowedSum inherit: the samples print as Java’s List.toString() and the doubles as Java’s Double.toString.

Source§

impl Measurable for SampledStat

Source§

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

Measure this quantity and return the result as a double. Read more
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. Read more
Source§

impl Stat for SampledStat

Source§

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

Record the given value. Read more

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<M> MetricValueProvider for M
where M: Measurable,

Source§

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

Returns the current value associated with this metric. Read more
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. Read more
Source§

fn as_measurable(&self) -> Option<&dyn Measurable>

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

Source§

impl<T> MeasurableStat for T
where T: Stat + Measurable,