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.

Source

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

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

Source

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

Create a Rate with the given unit and sampled stat.

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.

window is expressed in unit; when positive it configures the stat’s own time window (Java stat.withTimeWindow(window, unit)).

Source

pub fn unit_name(&self) -> String

The lower-cased name of the rate’s unit with the trailing “s” stripped (Java unitName()), 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.

Faithful translation of Rate.windowSize.

Trait Implementations§

Source§

impl Default for Rate

Source§

fn default() -> Self

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

impl Measurable for Rate

Source§

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

Measure this quantity and return the result as an f64. 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<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,