Skip to main content

WindowedCounterGroup

Struct WindowedCounterGroup 

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

A CounterGroup restricted to torn-safe windowed access.

Holds an inner base CounterGroup and exposes only the windowed writer/reader (set_with_window/load_with_window), the lock-free read accessors, and metadata — not the base group’s lock-free mutators (set/add/increment). Because no lock-free mutator is reachable, a windowless write is unrepresentable and torn-safety is enforced by the type. The window store and the atomic (value, window) pairing live on the inner base group (Phase-1 GroupWindows lock); this wrapper only narrows the API.

Implementations§

Source§

impl WindowedCounterGroup

Source

pub const fn new(entries: usize) -> Self

Create a windowed counter group with the given number of entries.

Source

pub fn entries(&self) -> usize

Return the number of entries in this group.

Source

pub fn set_with_window(&self, idx: usize, value: u64, window: Window) -> bool

Set the counter at idx to value and record its acquisition window as a torn-safe pair. Returns false if idx is out of bounds.

Source

pub fn load_with_window(&self, idx: usize) -> (Option<u64>, Option<Window>)

Load the counter at idx and its acquisition window as a torn-safe pair. Returns (None, None) if idx is out of bounds.

Source

pub fn value(&self, idx: usize) -> Option<u64>

Load the current value of the counter at idx.

Source

pub fn set_metadata(&self, idx: usize, metadata: HashMap<String, String>)

Set metadata for the entry at idx.

Source

pub fn insert_metadata(&self, idx: usize, key: String, value: String)

Set a single metadata key-value pair for the entry at idx.

Source

pub fn load_metadata(&self, idx: usize) -> Option<HashMap<String, String>>

Load metadata for the entry at idx.

Source

pub fn metadata_snapshot(&self) -> Vec<(usize, HashMap<String, String>)>

Snapshot all metadata.

Source

pub fn clear_metadata(&self, idx: usize)

Remove metadata for the entry at idx.

Trait Implementations§

Source§

impl Metric for WindowedCounterGroup

Source§

fn as_any(&self) -> Option<&dyn Any>

Get the current metric as an Any instance. This is meant to allow custom processing for known metric types.
Source§

fn value(&self) -> Option<Value<'_>>

Get the value of the current metric, should it be enabled. Read more
Source§

fn is_enabled(&self) -> bool

Indicate whether this metric has been set up. Read more
Source§

fn load_window(&self) -> Option<Window>

Get this metric’s acquisition window, if one has been recorded. Read more
Source§

fn value_with_window(&self) -> (Option<Value<'_>>, Option<Window>)

Get this metric’s value and its acquisition window as a torn-safe pair. Read more
Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

Provides type based access to context. 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.