Skip to main content

SampledStat

Struct SampledStat 

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

A SampledStat records a single scalar value measured over one or more samples. Each sample is recorded over a configurable window. The window can be defined by number of events or elapsed time (or both, if both are given the window is complete when either the event count or elapsed time criterion is met).

All the samples are combined to produce the measurement. When a window is complete the oldest sample is cleared and recycled to begin recording the next sample.

The mutable sample ring + cursor are guarded by a single Mutex mirroring Java’s sensor synchronized. This lock is taken per-fetch / per-partition, never per-record on the hot path (CLAUDE.md §13/§27).

Implementations§

Source§

impl SampledStat

Source

pub fn new(initial_value: f64, kind: Box<dyn SampledStatKind>) -> Self

Create a SampledStat with the given initial value and per-subclass behaviour.

Trait Implementations§

Source§

impl Measurable for SampledStat

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 SampledStat

Source§

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

Record the given value. 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> 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,