Skip to main content

SimpleRate

Struct SimpleRate 

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

A simple rate: the rate is incrementally calculated based on the elapsed time between the earliest reading and now.

An exception is made for the first window, which is considered of fixed size. This avoids the issue of an artificially high rate when the gap between readings is close to 0.

§Translation notes

Composes a Rate instead of extending it.

Implementations§

Source§

impl SimpleRate

Source

pub fn new() -> Self

Create a SimpleRate over seconds backed by a WindowedSum.

Source

pub fn window_size(&self, config: &MetricConfig, now: i64) -> i64

Compute the window size in milliseconds, overriding Rate::window_size: max(elapsed, config.timeWindowMs()).

§Arguments
  • config - the metric’s configuration
  • now - the current POSIX time in milliseconds
§Returns

The window size in milliseconds.

Trait Implementations§

Source§

impl Debug for SimpleRate

Source§

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

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

impl Default for SimpleRate

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Display for SimpleRate

Source§

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

Java’s Rate.toString(), which SimpleRate inherits.

Source§

impl Measurable for SimpleRate

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 SimpleRate

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,