Skip to main content

SharedHistogram

Struct SharedHistogram 

Source
pub struct SharedHistogram { /* private fields */ }

Implementations§

Source§

impl SharedHistogram

Source

pub fn create( path: impl AsRef<Path>, boundaries: &[u64], ) -> Result<Self, HistogramError>

Source

pub fn open( path: impl AsRef<Path>, expected_boundaries: &[u64], ) -> Result<Self, HistogramError>

Source

pub fn n_buckets(&self) -> usize

Number of buckets (n_boundaries + 1).

Source

pub fn total_count(&self) -> u64

Total count across all buckets.

Source

pub fn bucket_for(&self, value: u64) -> usize

Find the bucket index for value. Binary search on boundaries.

Source

pub fn record(&self, value: u64) -> usize

Record one observation of value. Atomically increments the matching bucket counter and the total. Returns the bucket index it landed in.

Source

pub fn count(&self, bucket_idx: usize) -> Result<u64, HistogramError>

Read a specific bucket’s count.

Source

pub fn counts(&self) -> Vec<u64>

Snapshot all bucket counts as a Vec.

Source

pub fn boundaries_vec(&self) -> Vec<u64>

Get the boundaries vector (copy).

Source

pub fn percentile(&self, p: f64) -> u64

Estimate the p-th percentile (p in 0.0..=1.0). Walks buckets accumulating counts until p of total is covered, then linearly interpolates within the target bucket. Returns 0 if total is 0.

Source

pub fn reset(&self)

Reset all counters to 0. Not concurrency-coordinated; expect transient race with concurrent recorders.

Source

pub fn flush(&self) -> Result<(), HistogramError>

Source

pub fn flush_async(&self) -> Result<(), HistogramError>

Trait Implementations§

Source§

impl AdaptiveInstance for SharedHistogram

Source§

fn header(&self) -> &HandshakeHeader

Source§

fn ring(&self) -> &ObservationRing

Source§

fn make_policy(&self) -> Box<dyn Policy>

Source§

fn apply_migration(&self, new_tag: u32)

Called by the sidecar when the policy returns a new strategy tag. Default implementation: just set the tag on the header. Primitives that need heavier migration (data-layout swap) override this to perform the swap before (or after) updating the tag.
Source§

impl Send for SharedHistogram

Source§

impl Sync for SharedHistogram

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.