Enum sentry_core::metrics::MetricValue
source · pub enum MetricValue {
Counter(CounterValue),
Distribution(DistributionValue),
Set(SetValue),
Gauge(GaugeValue),
}
Expand description
The value of a Metric
, indicating its type.
Variants§
Counter(CounterValue)
Counts instances of an event.
Counters can be incremented and decremented. The default operation is to increment a counter
by 1
, although increments by larger values and even floating point values are possible.
§Example
use sentry::metrics::{Metric, MetricValue};
Metric::build("my.counter", MetricValue::Counter(1.0)).send();
Distribution(DistributionValue)
Builds a statistical distribution over values reported.
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.
§Example
use sentry::metrics::{Metric, MetricValue};
Metric::build("my.distribution", MetricValue::Distribution(42.0)).send();
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.
§Example
To create a set value, use MetricValue::set_from_str
or
MetricValue::set_from_display
. These functions convert the provided argument into a
unique hash value, which is then used as the set value.
use sentry::metrics::{Metric, MetricValue};
Metric::build("my.set", MetricValue::set_from_str("foo")).send();
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.
§Example
use sentry::metrics::{Metric, MetricValue};
Metric::build("my.gauge", MetricValue::Gauge(42.0)).send();
Implementations§
source§impl MetricValue
impl MetricValue
sourcepub fn set_from_str(string: &str) -> Self
pub fn set_from_str(string: &str) -> Self
Returns a set value representing the given string.
sourcepub fn set_from_display(display: impl Display) -> Self
pub fn set_from_display(display: impl Display) -> Self
Returns a set value representing the given argument.
Trait Implementations§
source§impl Clone for MetricValue
impl Clone for MetricValue
source§fn clone(&self) -> MetricValue
fn clone(&self) -> MetricValue
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for MetricValue
impl Debug for MetricValue
source§impl Display for MetricValue
impl Display for MetricValue
source§impl PartialEq for MetricValue
impl PartialEq for MetricValue
source§fn eq(&self, other: &MetricValue) -> bool
fn eq(&self, other: &MetricValue) -> bool
self
and other
values to be equal, and is used
by ==
.