Enum relay_metrics::BucketValue
source · 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.
§Statsd Format
Counters are declared as "c"
. Alternatively, "m"
is allowed.
There can be a variable number of floating point values. If more than one value is given, the values are summed into a single counter value:
endpoint.hits:4.5:21:17.0|c
§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.
§Statsd Format
Distributions are declared as "d"
. Alternatively, "d"
and "ms"
are allowed.
There can be a variable number of floating point values. These values are collected directly in a list per bucket.
endpoint.response_time@millisecond:36:49:57:68|d
§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 allow sending arbitrary discrete values, including strings, and store the 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.
§Statsd Format
Sets are declared as "s"
. Values in the list should be deduplicated.
endpoint.users:3182887624:4267882815|s
endpoint.users:e2546e4c-ecd0-43ad-ae27-87960e57a658|s
§Serialization
This variant serializes to a list of 32-bit integers.
§Aggregation
Set values are internally represented as 32-bit integer hashes of the original value. These hashes can be ingested directly as seen in the first example above. If raw strings are sent, they will be hashed on-the-fly.
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.
§Statsd Format
Gauges are declared as "g"
. There are two ways to ingest gauges:
- As a single value. In this case, the provided value is assumed as the last, minimum, maximum, and the sum.
- As a sequence of five values in the order:
last
,min
,max
,sum
,count
.
endpoint.parallel_requests:25|g
endpoint.parallel_requests:25:17:42:220:85|g
§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:
last
assumes the newly added valuemin
retains the smaller valuemax
retains the larger valuesum
adds the new value to the existing sumcount
adds 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 a single given string value.
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 · 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 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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)