pub enum BucketValue {
Counter(CounterType),
Distribution(DistributionValue),
Set(SetValue),
Gauge(GaugeValue),
}Expand description
The aggregated value of a metric bucket.
Variants§
Counter(CounterType)
Counts instances of an event (MetricType::Counter).
Counters can be incremented and decremented. The default operation is to increment a counter
by 1, although increments by larger values are equally possible.
§Serialization
This variant serializes to a double precision float.
§Aggregation
Counters aggregate by folding individual values into a single sum value per bucket. The sum is ingested and stored directly.
Distribution(DistributionValue)
Builds a statistical distribution over values reported (MetricType::Distribution).
Based on individual reported values, distributions allow to query the maximum, minimum, or average of the reported values, as well as statistical quantiles. With an increasing number of values in the distribution, its accuracy becomes approximate.
§Serialization
This variant serializes to a list of double precision floats, see DistributionValue.
§Aggregation
During ingestion, all individual reported values are collected in a lossless format. In storage, these values are compressed into data sketches that allow to query quantiles. Separately, the count and sum of the reported values is stored, which makes distributions a strict superset of counters.
Set(SetValue)
Counts the number of unique reported values.
Sets represent arbitrary discrete values as hashes and track their deduplicated count. With an increasing number of unique values in the set, its accuracy becomes approximate. It is not possible to query individual values from a set.
§Serialization
This variant serializes to a list of 32-bit integers.
§Aggregation
Set values are represented as 32-bit integer hashes of the original value. Buckets merge by taking the union of these hashes.
Internally, set metrics are stored in data sketches that expose an approximate cardinality.
Gauge(GaugeValue)
Stores absolute snapshots of values.
In addition to plain counters, gauges store a snapshot of the maximum, minimum and sum of all values, as well as the last reported value. Note that the “last” component of this aggregation is not commutative. Which value is preserved as last value is implementation-defined.
§Serialization
This variant serializes to a structure with named fields, see GaugeValue.
§Aggregation
Gauges aggregate by folding each of the components based on their semantics:
lastassumes the newly added valueminretains the smaller valuemaxretains the larger valuesumadds the new value to the existing sumcountadds the count of the newly added gauge (defaulting to1)
Implementations§
Source§impl BucketValue
impl BucketValue
Sourcepub fn counter(value: CounterType) -> Self
pub fn counter(value: CounterType) -> Self
Returns a bucket value representing a counter with the given value.
Sourcepub fn distribution(value: DistributionType) -> Self
pub fn distribution(value: DistributionType) -> Self
Returns a bucket value representing a distribution with a single given value.
Sourcepub fn set(value: SetType) -> Self
pub fn set(value: SetType) -> Self
Returns a bucket value representing a set with a single given hash value.
Sourcepub fn set_from_str(string: &str) -> Self
pub fn set_from_str(string: &str) -> Self
Returns a bucket value representing a set with the 32-bit hash of the given string.
Sourcepub fn set_from_display(display: impl Display) -> Self
pub fn set_from_display(display: impl Display) -> Self
Returns a bucket value representing a set with a single given value.
Sourcepub fn gauge(value: GaugeType) -> Self
pub fn gauge(value: GaugeType) -> Self
Returns a bucket value representing a gauge with a single given value.
Sourcepub fn ty(&self) -> MetricType
pub fn ty(&self) -> MetricType
Returns the type of this value.
Trait Implementations§
Source§impl Clone for BucketValue
impl Clone for BucketValue
Source§fn clone(&self) -> BucketValue
fn clone(&self) -> BucketValue
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for BucketValue
impl Debug for BucketValue
Source§impl<'de> Deserialize<'de> for BucketValue
impl<'de> Deserialize<'de> for BucketValue
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>,
Source§impl<'a> From<&'a BucketValue> for BucketViewValue<'a>
impl<'a> From<&'a BucketValue> for BucketViewValue<'a>
Source§fn from(value: &'a BucketValue) -> Self
fn from(value: &'a BucketValue) -> Self
Source§impl PartialEq for BucketValue
impl PartialEq for BucketValue
Source§impl Serialize for BucketValue
impl Serialize for BucketValue
impl StructuralPartialEq for BucketValue
Auto Trait Implementations§
impl Freeze for BucketValue
impl RefUnwindSafe for BucketValue
impl Send for BucketValue
impl Sync for BucketValue
impl Unpin for BucketValue
impl UnsafeUnpin for BucketValue
impl UnwindSafe for BucketValue
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>,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
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