Skip to main content

Sample

Struct Sample 

Source
#[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

Source

pub fn new(initial_value: f64, now: i64) -> Self

Create a sample with no explicit time window.

Source

pub fn with_time_window_ms( initial_value: f64, now: i64, time_window_ms: i64, ) -> Self

Create a sample with an explicit time window.

Source

pub fn reset(&mut self, now: i64)

Reset the sample for reuse at now, keeping its configured initial value.

Source

pub fn is_complete(&self, time_ms: i64, config: &MetricConfig) -> bool

Whether this sample’s window is complete at time_ms.

Source

pub fn initial_value(&self) -> f64

The initial (reset) value of this sample.

Java’s public Sample.initialValue.

Source

pub fn event_count(&self) -> i64

The number of events recorded into this sample.

Java’s public Sample.eventCount.

Source

pub fn start_time_ms(&self) -> i64

The time the sample started.

Java’s public Sample.startTimeMs.

Source

pub fn last_event_ms(&self) -> i64

The time of the last event recorded into the sample.

Java’s public Sample.lastEventMs.

Source

pub fn value(&self) -> f64

The accumulated value of the sample.

Java’s public Sample.value.

Source

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.

Source

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.

Source

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.

Source

pub fn set_value(&mut self, value: f64)

Sets the accumulated value of the sample, as Java’s Avg, Max, Min and WindowedSum do through the public Sample.value.

Trait Implementations§

Source§

impl Clone for Sample

Source§

fn clone(&self) -> Sample

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Sample

Source§

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

Formats the value using the given formatter. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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