pub enum MetricValue {
Count {
value: f64,
},
Rate {
interval: u64,
value: f64,
},
Gauge {
value: f64,
},
Sketch {
sketch: DDSketch,
},
}
Expand description
A metric value.
§Equality
MetricValue
implements PartialEq
and Eq
, the majority of which involves comparing floating-point (f64
)
numbers. Comparing floating-point numbers for equality is inherently tricky (this is just one blog
post/article out of thousands on the subject). In the equality implementation for MetricValue
, we use a
ratio-based approach.
This means that when comparing two floating-point numbers, we look at their ratio to one another, with an upper
bound on the allowed difference. For example, if we compare 99 to 100, there’s a difference of 1% (1 - (99/100) = 0.01 = 1%
), while the difference between 99.999 and 100 is only 0.001% (1 - (99.999/100) = 0.00001 = 0.001%
). As
most comparisons are expected to be close, only differing by a few ULPs (units in the last place) due to slight
differences in how floating-point numbers are implemented between Go and Rust, this approach is sufficient to
compensate for the inherent imprecision while not falling victim to relying on ULPs or epsilon directly, whose
applicability depends on the number range being compared.
Specifically, we compare floating-point numbers using a ratio of 0.00000001
(0.0000001%), meaning the smaller of
the two values being compared must be within 99.999999% to 100% of the larger number, which is sufficiently precise
for our concerns.
Variants§
Count
A count.
Rate
A rate.
Rates are per-second adjusted counts. For example, a count that increased by 100 over 10 seconds would be
represented as a rate with an interval of 10 (seconds) and a value of 10 (100 / 10 = 10
).
Fields
Gauge
A gauge.
Sketch
A sketch.
Fields
sketch: DDSketch
The sketch data.
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<'de> Deserialize<'de> for MetricValue
impl<'de> Deserialize<'de> for MetricValue
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 PartialEq for MetricValue
impl PartialEq for MetricValue
Source§impl Serialize for MetricValue
impl Serialize for MetricValue
impl Eq for MetricValue
Auto Trait Implementations§
impl Freeze for MetricValue
impl RefUnwindSafe for MetricValue
impl Send for MetricValue
impl Sync for MetricValue
impl Unpin for MetricValue
impl UnwindSafe for MetricValue
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§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request