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
impl Rate
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a Rate over seconds backed by a WindowedSum.
Sourcepub fn with_unit(unit: TimeUnit) -> Self
pub fn with_unit(unit: TimeUnit) -> Self
Create a Rate with the given unit backed by a WindowedSum.
Sourcepub fn with_stat(stat: Arc<SampledStat>) -> Self
pub fn with_stat(stat: Arc<SampledStat>) -> Self
Create a Rate over seconds backed by the given sampled stat.
Sourcepub fn with_unit_stat(unit: TimeUnit, stat: Arc<SampledStat>) -> Self
pub fn with_unit_stat(unit: TimeUnit, stat: Arc<SampledStat>) -> Self
Create a Rate with the given unit and sampled stat.
Sourcepub fn with_unit_stat_window(
unit: TimeUnit,
stat: Arc<SampledStat>,
window: i64,
) -> Self
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)).
Sourcepub fn unit_name(&self) -> String
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.
Sourcepub fn window_size(&self, config: &MetricConfig, now: i64) -> i64
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.