#[non_exhaustive]pub struct Sample { /* private fields */ }Expand description
A single sample within a SampledStat.
Mirrors SampledStat.Sample. Java exposes the fields publicly to
SampledStat subclasses; here a SampledStatKind implementation reads
them through getters and writes the ones Java’s stats write through setters.
Implementations§
Source§impl Sample
impl Sample
Sourcepub fn with_time_window_ms(
initial_value: f64,
now: i64,
time_window_ms: i64,
) -> Self
pub fn with_time_window_ms( initial_value: f64, now: i64, time_window_ms: i64, ) -> Self
Create a sample with an explicit time window.
Sourcepub fn reset(&mut self, now: i64)
pub fn reset(&mut self, now: i64)
Reset the sample for reuse at now, keeping its configured initial value.
Sourcepub fn is_complete(&self, time_ms: i64, config: &MetricConfig) -> bool
pub fn is_complete(&self, time_ms: i64, config: &MetricConfig) -> bool
Whether this sample’s window is complete at time_ms.
Sourcepub fn initial_value(&self) -> f64
pub fn initial_value(&self) -> f64
The initial (reset) value of this sample.
Java’s public Sample.initialValue.
Sourcepub fn event_count(&self) -> i64
pub fn event_count(&self) -> i64
The number of events recorded into this sample.
Java’s public Sample.eventCount.
Sourcepub fn start_time_ms(&self) -> i64
pub fn start_time_ms(&self) -> i64
The time the sample started.
Java’s public Sample.startTimeMs.
Sourcepub fn last_event_ms(&self) -> i64
pub fn last_event_ms(&self) -> i64
The time of the last event recorded into the sample.
Java’s public Sample.lastEventMs.
Sourcepub fn time_window_ms(&self) -> i64
pub fn time_window_ms(&self) -> i64
The per-sample time window (or -1 to use the config’s window).
Java’s public Sample.timeWindowMs.
Sourcepub fn set_event_count(&mut self, event_count: i64)
pub fn set_event_count(&mut self, event_count: i64)
Sets the number of events recorded into this sample, as Java’s
SampledStat.record does through the public Sample.eventCount.
Sourcepub fn set_last_event_ms(&mut self, last_event_ms: i64)
pub fn set_last_event_ms(&mut self, last_event_ms: i64)
Sets the time of the last event recorded into the sample, as Java’s
SampledStat.record does through the public Sample.lastEventMs.