pub enum MetricValues {
Counter(ScalarPoints),
Rate(ScalarPoints, Duration),
Gauge(ScalarPoints),
Set(SetPoints),
Histogram(HistogramPoints),
Distribution(SketchPoints),
}
Expand description
The values of a metric.
Variants§
Counter(ScalarPoints)
A counter.
Counters generally represent a monotonically increasing value, such as the number of requests received.
Rate(ScalarPoints, Duration)
A rate.
Rates define the rate of change over a given interval.
For example, a rate with a value of 15 and an interval of 10 seconds would indicate that the value increases by 15 every 10 seconds, or 1.5 per second.
Gauge(ScalarPoints)
A gauge.
Gauges represent the latest value of a quantity, such as the current number of active connections. This value can go up or down, but gauges do not track the individual changes to the value, only the latest value.
Set(SetPoints)
A set.
Sets represent a collection of unique values, such as the unique IP addresses that have connected to a service.
Histogram(HistogramPoints)
A histogram.
Histograms represent the distribution of a quantity, such as the response times for a service, with forced client-side aggregation. Individual samples are stored locally, in full fidelity, and aggregate statistics can be queried against the sample set, but the individual samples cannot be accessed.
Distribution(SketchPoints)
A distribution.
Distributions represent the distribution of a quantity, such as the response times for a service, in such a way that server-side aggregation is possible. Individual samples are stored in a sketch, which supports being merged with other sketches server-side to facilitate global aggregation.
Like histograms, sketches also provide the ability to be queried for aggregate statistics but the individual samples cannot be accessed.
Implementations§
Source§impl MetricValues
impl MetricValues
Sourcepub fn counter<V>(values: V) -> Selfwhere
V: Into<ScalarPoints>,
pub fn counter<V>(values: V) -> Selfwhere
V: Into<ScalarPoints>,
Creates a set of counter values from the given value(s).
Sourcepub fn counter_sampled_fallible<I, E>(
iter: I,
sample_rate: Option<SampleRate>,
) -> Result<Self, E>
pub fn counter_sampled_fallible<I, E>( iter: I, sample_rate: Option<SampleRate>, ) -> Result<Self, E>
Creates a set of counter values from a fallible iterator of values, based on the given sample rate.
If sample_rate
is None
, no values will be modified. Otherwise, each value will be scaled proportionally to
the quotient of 1 / sample_rate
.
Sourcepub fn gauge<V>(values: V) -> Selfwhere
V: Into<ScalarPoints>,
pub fn gauge<V>(values: V) -> Selfwhere
V: Into<ScalarPoints>,
Creates a set of gauge values from the given value(s).
Sourcepub fn gauge_fallible<I, E>(iter: I) -> Result<Self, E>
pub fn gauge_fallible<I, E>(iter: I) -> Result<Self, E>
Creates a set of gauge values from a fallible iterator of values.
Sourcepub fn histogram<V>(values: V) -> Selfwhere
V: Into<HistogramPoints>,
pub fn histogram<V>(values: V) -> Selfwhere
V: Into<HistogramPoints>,
Creates a set of histogram values from the given value(s).
Sourcepub fn histogram_sampled_fallible<I, E>(
iter: I,
sample_rate: Option<SampleRate>,
) -> Result<Self, E>
pub fn histogram_sampled_fallible<I, E>( iter: I, sample_rate: Option<SampleRate>, ) -> Result<Self, E>
Creates a set of histogram values from a fallible iterator of values, based on the given sample rate.
If sample_rate
is None
, only the values present in the iterator will be used. Otherwise, each value will be
inserted at a scaled count of 1 / sample_rate
.
Sourcepub fn distribution<V>(values: V) -> Selfwhere
V: Into<SketchPoints>,
pub fn distribution<V>(values: V) -> Selfwhere
V: Into<SketchPoints>,
Creates a set of distribution values from the given value(s).
Sourcepub fn distribution_sampled_fallible<I, E>(
iter: I,
sample_rate: Option<SampleRate>,
) -> Result<Self, E>
pub fn distribution_sampled_fallible<I, E>( iter: I, sample_rate: Option<SampleRate>, ) -> Result<Self, E>
Creates a set of distribution values from a fallible iterator of values, based on the given sample rate.
If sample_rate
is None
, only the values present in the iterator will be used. Otherwise, each value will be
inserted at a scaled count of 1 / sample_rate
.
Sourcepub fn rate<V>(values: V, interval: Duration) -> Selfwhere
V: Into<ScalarPoints>,
pub fn rate<V>(values: V, interval: Duration) -> Selfwhere
V: Into<ScalarPoints>,
Creates a set of rate values from the given value(s) and interval.
Sourcepub fn all_timestamped(&self) -> bool
pub fn all_timestamped(&self) -> bool
Returns true
if all values in this metric have a timestamp.
Sourcepub fn any_timestamped(&self) -> bool
pub fn any_timestamped(&self) -> bool
Returns true
if any values in this metric have a timestamp.
Sourcepub fn set_timestamp(&mut self, timestamp: u64)
pub fn set_timestamp(&mut self, timestamp: u64)
Sets the timestamp for all values in this metric.
This overrides all existing timestamps whether they are set or not. If timestamp
is zero, all existing
timestamps will be cleared.
Sourcepub fn split_timestamped(&mut self) -> Self
pub fn split_timestamped(&mut self) -> Self
Splits all timestamped values into a new MetricValues
, leaving the remaining values in self
.
Sourcepub fn split_at_timestamp(&mut self, timestamp: u64) -> Option<Self>
pub fn split_at_timestamp(&mut self, timestamp: u64) -> Option<Self>
Splits all values with a timestamp less than or equal to timestamp
into a new MetricValues
, leaving the
remaining values in self
.
Sourcepub fn collapse_non_timestamped(&mut self, timestamp: u64)
pub fn collapse_non_timestamped(&mut self, timestamp: u64)
Collapses all non-timestamped values into a single value with the given timestamp.
Sourcepub fn merge(&mut self, other: Self)
pub fn merge(&mut self, other: Self)
Merges another set of metric values into this one.
If both self
and other
are the same metric type, their values will be merged appropriately. If the metric
types are different, or a specific precondition for the metric type is not met, the incoming values will override
the existing values instead.
For rates, the interval of both rates must match to be merged. For gauges, the incoming value will override the existing value.
Trait Implementations§
Source§impl Clone for MetricValues
impl Clone for MetricValues
Source§fn clone(&self) -> MetricValues
fn clone(&self) -> MetricValues
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for MetricValues
impl Debug for MetricValues
Source§impl Display for MetricValues
impl Display for MetricValues
Source§impl PartialEq for MetricValues
impl PartialEq for MetricValues
impl Eq for MetricValues
impl StructuralPartialEq for MetricValues
Auto Trait Implementations§
impl Freeze for MetricValues
impl RefUnwindSafe for MetricValues
impl Send for MetricValues
impl Sync for MetricValues
impl Unpin for MetricValues
impl UnwindSafe for MetricValues
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
Source§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> Track for T
impl<T> Track for T
§fn track_allocations(self, token: AllocationGroupToken) -> Tracked<Self>
fn track_allocations(self, token: AllocationGroupToken) -> Tracked<Self>
Tracked
wrapper. Read more§fn in_current_allocation_group(self) -> Tracked<Self>
fn in_current_allocation_group(self) -> Tracked<Self>
Tracked
wrapper. Read more