MetricValues

Enum MetricValues 

Source
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

Source

pub fn counter<V>(values: V) -> Self
where V: Into<ScalarPoints>,

Creates a set of counter values from the given value(s).

Source

pub fn counter_sampled_fallible<I, E>( iter: I, sample_rate: Option<SampleRate>, ) -> Result<Self, E>
where I: Iterator<Item = Result<f64, 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.

Source

pub fn gauge<V>(values: V) -> Self
where V: Into<ScalarPoints>,

Creates a set of gauge values from the given value(s).

Source

pub fn gauge_fallible<I, E>(iter: I) -> Result<Self, E>
where I: Iterator<Item = Result<f64, E>>,

Creates a set of gauge values from a fallible iterator of values.

Source

pub fn set<V>(values: V) -> Self
where V: Into<SetPoints>,

Creates a set from the given values.

Source

pub fn histogram<V>(values: V) -> Self

Creates a set of histogram values from the given value(s).

Source

pub fn histogram_sampled_fallible<I, E>( iter: I, sample_rate: Option<SampleRate>, ) -> Result<Self, E>
where I: Iterator<Item = Result<f64, 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.

Source

pub fn distribution<V>(values: V) -> Self
where V: Into<SketchPoints>,

Creates a set of distribution values from the given value(s).

Source

pub fn distribution_sampled_fallible<I, E>( iter: I, sample_rate: Option<SampleRate>, ) -> Result<Self, E>
where I: Iterator<Item = Result<f64, 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.

Source

pub fn rate<V>(values: V, interval: Duration) -> Self
where V: Into<ScalarPoints>,

Creates a set of rate values from the given value(s) and interval.

Source

pub fn is_empty(&self) -> bool

Returns true if this metric has no values.

Source

pub fn len(&self) -> usize

Returns the number of values in this metric.

Source

pub fn all_timestamped(&self) -> bool

Returns true if all values in this metric have a timestamp.

Source

pub fn any_timestamped(&self) -> bool

Returns true if any values in this metric have a timestamp.

Source

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.

Source

pub fn split_timestamped(&mut self) -> Self

Splits all timestamped values into a new MetricValues, leaving the remaining values in self.

Source

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.

Source

pub fn collapse_non_timestamped(&mut self, timestamp: u64)

Collapses all non-timestamped values into a single value with the given timestamp.

Source

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.

Source

pub fn as_str(&self) -> &'static str

Returns the metric value type as a string.

Source

pub fn is_serie(&self) -> bool

Returns true if this metric is a serie.

Source

pub fn is_sketch(&self) -> bool

Returns true if this metric is a sketch.

Trait Implementations§

Source§

impl Clone for MetricValues

Source§

fn clone(&self) -> MetricValues

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MetricValues

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for MetricValues

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for MetricValues

Source§

fn eq(&self, other: &MetricValues) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for MetricValues

Source§

impl StructuralPartialEq for MetricValues

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<T> Stringable for T
where T: Display,

§

fn to_shared_string(&self) -> Cow<'static, str>

Converts the given value to a SharedString.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
§

impl<T> Track for T

§

fn track_allocations(self, token: AllocationGroupToken) -> Tracked<Self>

Instruments this type by attaching the given allocation group token, returning a Tracked wrapper. Read more
§

fn in_current_allocation_group(self) -> Tracked<Self>

Instruments this type by attaching the current allocation group, returning a Tracked wrapper. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more