Skip to main content

Rate

Struct Rate 

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

The rate of the given quantity. By default this is the total observed over a set of samples from a sampled statistic divided by the elapsed time over the sample windows. Alternative SampledStat implementations can be provided, however, to record the rate of occurrences (e.g. the count of values measured over the time interval) or other such values.

Implementations§

Source§

impl Rate

Source

pub fn new() -> Self

Create a Rate over seconds backed by a WindowedSum.

Source

pub fn with_unit(unit: TimeUnit) -> Self

Create a Rate with the given unit backed by a WindowedSum.

§Arguments
  • unit - the time unit of the rate
Source

pub fn with_stat(stat: Arc<SampledStat>) -> Self

Create a Rate over seconds backed by the given sampled stat.

§Arguments
  • stat - the sampled stat whose total the rate divides
Source

pub fn with_unit_stat(unit: TimeUnit, stat: Arc<SampledStat>) -> Self

Create a Rate with the given unit and sampled stat.

§Arguments
  • unit - the time unit of the rate
  • stat - the sampled stat whose total the rate divides
Source

pub fn with_unit_stat_window( unit: TimeUnit, stat: Arc<SampledStat>, window: i64, ) -> Self

Create a Rate with the given unit, sampled stat and explicit window.

§Arguments
  • unit - the time unit of the rate and of window
  • stat - the sampled stat whose total the rate divides
  • window - when positive, the stat’s own time window, in unit
Source

pub fn unit_name(&self) -> String

Returns the lower-cased name of the rate’s unit with the trailing “s” stripped, e.g. SECONDS -> second.

Source

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

Compute the window size in milliseconds used for the rate calculation.

§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 Rate

Source§

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

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

impl Default for Rate

Source§

fn default() -> Self

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

impl Display for Rate

Source§

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

Java’s toString(), which SimpleRate inherits.

Source§

impl Measurable for Rate

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 Rate

Source§

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

Record the given value. Read more

Auto Trait Implementations§

§

impl Freeze for Rate

§

impl !RefUnwindSafe for Rate

§

impl Send for Rate

§

impl Sync for Rate

§

impl Unpin for Rate

§

impl UnsafeUnpin for Rate

§

impl !UnwindSafe for Rate

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,