pub struct SharedHistogram { /* private fields */ }Implementations§
pub fn create( path: impl AsRef<Path>, boundaries: &[u64], ) -> Result<Self, HistogramError>
pub fn open( path: impl AsRef<Path>, expected_boundaries: &[u64], ) -> Result<Self, HistogramError>
Sourcepub fn total_count(&self) -> u64
pub fn total_count(&self) -> u64
Total count across all buckets.
Sourcepub fn bucket_for(&self, value: u64) -> usize
pub fn bucket_for(&self, value: u64) -> usize
Find the bucket index for value. Binary search on boundaries.
Sourcepub fn record(&self, value: u64) -> usize
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.
Sourcepub fn count(&self, bucket_idx: usize) -> Result<u64, HistogramError>
pub fn count(&self, bucket_idx: usize) -> Result<u64, HistogramError>
Read a specific bucket’s count.
Sourcepub fn boundaries_vec(&self) -> Vec<u64>
pub fn boundaries_vec(&self) -> Vec<u64>
Get the boundaries vector (copy).
Sourcepub fn percentile(&self, p: f64) -> u64
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.
Sourcepub fn reset(&self)
pub fn reset(&self)
Reset all counters to 0. Not concurrency-coordinated; expect transient race with concurrent recorders.
pub fn flush(&self) -> Result<(), HistogramError>
pub fn flush_async(&self) -> Result<(), HistogramError>
Trait Implementations§
fn header(&self) -> &HandshakeHeader
fn ring(&self) -> &ObservationRing
fn make_policy(&self) -> Box<dyn Policy>
Source§fn apply_migration(&self, new_tag: u32)
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.
Auto Trait Implementations§
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more