pub struct Histogram {
pub buckets: Vec<f64>,
pub counts: Vec<u64>,
pub count: u64,
pub sum: f64,
}Expand description
A fixed-bucket distribution (§2.8), cumulative within one epoch, as
ZenSight’s HistogramValue is.
Fields§
§buckets: Vec<f64>The bounds, strictly ascending and finite, +Inf implicit: equal by
value to the resource’s telemetry.buckets.
counts: Vec<u64>A count per bucket, not cumulative, one more than the bounds, the overflow last.
count: u64The sum of counts.
sum: f64The sum of every value observed, which may be negative.
Implementations§
Source§impl Histogram
impl Histogram
Sourcepub fn new(bounds: &[f64]) -> Option<Self>
pub fn new(bounds: &[f64]) -> Option<Self>
An empty histogram over bounds, the declared telemetry.buckets
(the declaration’s super::Declared::buckets). None unless they
are a valid set of bounds (§2.2): non-empty, finite, strictly
ascending.
Sourcepub fn bucket_of(&self, v: f64) -> usize
pub fn bucket_of(&self, v: f64) -> usize
The bucket a value falls in (§2.8): the first bound at or above it,
(buckets[i-1], buckets[i]], upper-inclusive; past the last bound,
the overflow.
Sourcepub fn observe(&mut self, v: f64) -> bool
pub fn observe(&mut self, v: f64) -> bool
Records one observation: its bucket’s count and count up by one,
v added to sum. Refused, false and nothing changed, for a
value that is not finite (it has no bucket), and for one that would
take a count past 2^64−1 or the sum to an infinity, either of which
would make the histogram one no reader reads (§2.6).
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Histogram
impl<'de> Deserialize<'de> for Histogram
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl StructuralPartialEq for Histogram
Auto Trait Implementations§
impl Forget for Histogram
impl Freeze for Histogram
impl Move for Histogram
impl RefUnwindSafe for Histogram
impl Send for Histogramwhere
RawVecInner: Send,
impl Sync for Histogramwhere
RawVecInner: Sync,
impl Unpin for Histogram
impl UnsafeUnpin for Histogramwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<f64>: UnsafeUnpin,
PhantomData<u64>: UnsafeUnpin,
impl UnwindSafe for Histogramwhere
RawVecInner: UnwindSafe,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more