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