pub struct Metric {
pub name: String,
pub description: String,
pub unit: String,
pub metadata: Vec<KeyValue>,
pub data: Option<Data>,
}
gen-tonic-messages
and metrics
only.Expand description
Defines a Metric which has one or more timeseries. The following is a brief summary of the Metric data model. For more details, see:
The data model and relation between entities is shown in the diagram below. Here, “DataPoint” is the term used to refer to any one of the specific data point value types, and “points” is the term used to refer to any one of the lists of points contained in the Metric.
-
Metric is composed of a metadata and data.
-
Metadata part contains a name, description, unit.
-
Data is one of the possible types (Sum, Gauge, Histogram, Summary).
-
DataPoint contains timestamps, attributes, and one of the possible value type fields.
Metric +————+ |name | |description | |unit | +————————————+ |data |—> |Gauge, Sum, Histogram, Summary, … | +————+ +————————————+
Data [One of Gauge, Sum, Histogram, Summary, …] +———–+ |… | // Metadata about the Data. |points |–+ +———–+ | | +—————————+ | |DataPoint 1 | v |+——+——+ +——+ | +—–+ ||label |label |…|label | | | 1 |–>||value1|value2|…|valueN| | +—–+ |+——+——+ +——+ | | . | |+—–+ | | . | ||value| | | . | |+—–+ | | . | +—————————+ | . | . | . | . | . | . | . | +—————————+ | . | |DataPoint M | +—–+ |+——+——+ +——+ | | M |–>||label |label |…|label | | +—–+ ||value1|value2|…|valueN| | |+——+——+ +——+ | |+—–+ | ||value| | |+—–+ | +—————————+
Each distinct type of DataPoint represents the output of a specific aggregation function, the result of applying the DataPoint’s associated function of to one or more measurements.
All DataPoint types have three common fields:
- Attributes includes key-value pairs associated with the data point
- TimeUnixNano is required, set to the end time of the aggregation
- StartTimeUnixNano is optional, but strongly encouraged for DataPoints having an AggregationTemporality field, as discussed below.
Both TimeUnixNano and StartTimeUnixNano values are expressed as UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970.
§TimeUnixNano
This field is required, having consistent interpretation across DataPoint types. TimeUnixNano is the moment corresponding to when the data point’s aggregate value was captured.
Data points with the 0 value for TimeUnixNano SHOULD be rejected by consumers.
§StartTimeUnixNano
StartTimeUnixNano in general allows detecting when a sequence of observations is unbroken. This field indicates to consumers the start time for points with cumulative and delta AggregationTemporality, and it should be included whenever possible to support correct rate calculation. Although it may be omitted when the start time is truly unknown, setting StartTimeUnixNano is strongly encouraged.
Fields§
§name: String
name of the metric.
description: String
description of the metric, which can be used in documentation.
unit: String
unit in which the metric value is reported. Follows the format described by http://unitsofmeasure.org/ucum.html.
metadata: Vec<KeyValue>
Additional metadata attributes that describe the metric. [Optional]. Attributes are non-identifying. Consumers SHOULD NOT need to be aware of these attributes. These attributes MAY be used to encode information allowing for lossless roundtrip translation to / from another data model. Attribute keys MUST be unique (it is not allowed to have more than one attribute with the same key).
data: Option<Data>
Data determines the aggregation type (if any) of the metric, what is the reported value type for the data points, as well as the relatationship to the time interval over which they are reported.
Trait Implementations§
source§impl<'de> Deserialize<'de> for Metric
impl<'de> Deserialize<'de> for Metric
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 Message for Metric
impl Message for Metric
source§fn encoded_len(&self) -> usize
fn encoded_len(&self) -> usize
source§fn encode(&self, buf: &mut impl BufMut) -> Result<(), EncodeError>where
Self: Sized,
fn encode(&self, buf: &mut impl BufMut) -> Result<(), EncodeError>where
Self: Sized,
source§fn encode_to_vec(&self) -> Vec<u8>where
Self: Sized,
fn encode_to_vec(&self) -> Vec<u8>where
Self: Sized,
source§fn encode_length_delimited(
&self,
buf: &mut impl BufMut,
) -> Result<(), EncodeError>where
Self: Sized,
fn encode_length_delimited(
&self,
buf: &mut impl BufMut,
) -> Result<(), EncodeError>where
Self: Sized,
source§fn encode_length_delimited_to_vec(&self) -> Vec<u8>where
Self: Sized,
fn encode_length_delimited_to_vec(&self) -> Vec<u8>where
Self: Sized,
source§fn decode(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
fn decode(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
source§fn decode_length_delimited(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
fn decode_length_delimited(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
source§fn merge(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
fn merge(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
self
. Read moresource§fn merge_length_delimited(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
fn merge_length_delimited(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
self
.impl StructuralPartialEq for Metric
Auto Trait Implementations§
impl Freeze for Metric
impl RefUnwindSafe for Metric
impl Send for Metric
impl Sync for Metric
impl Unpin for Metric
impl UnwindSafe for Metric
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
)source§impl<T> FutureExt for T
impl<T> FutureExt for T
source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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