Struct opentelemetry_proto::tonic::metrics::v1::Metric

source ·
pub struct Metric {
    pub name: String,
    pub description: String,
    pub unit: String,
    pub metadata: Vec<KeyValue>,
    pub data: Option<Data>,
}
Available on crate features 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:

https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/data-model.md

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 Clone for Metric

source§

fn clone(&self) -> Metric

Returns a copy 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 Metric

source§

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

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

impl Default for Metric

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for Metric

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl From<&Metric> for Metric

source§

fn from(metric: &SdkMetric) -> Self

Converts to this type from the input type.
source§

impl Message for Metric

source§

fn encoded_len(&self) -> usize

Returns the encoded length of the message without a length delimiter.
source§

fn clear(&mut self)

Clears the message, resetting all fields to their default.
source§

fn encode(&self, buf: &mut impl BufMut) -> Result<(), EncodeError>
where Self: Sized,

Encodes the message to a buffer. Read more
source§

fn encode_to_vec(&self) -> Vec<u8>
where Self: Sized,

Encodes the message to a newly allocated buffer.
source§

fn encode_length_delimited( &self, buf: &mut impl BufMut, ) -> Result<(), EncodeError>
where Self: Sized,

Encodes the message with a length-delimiter to a buffer. Read more
source§

fn encode_length_delimited_to_vec(&self) -> Vec<u8>
where Self: Sized,

Encodes the message with a length-delimiter to a newly allocated buffer.
source§

fn decode(buf: impl Buf) -> Result<Self, DecodeError>
where Self: Default,

Decodes an instance of the message from a buffer. Read more
source§

fn decode_length_delimited(buf: impl Buf) -> Result<Self, DecodeError>
where Self: Default,

Decodes a length-delimited instance of the message from the buffer.
source§

fn merge(&mut self, buf: impl Buf) -> Result<(), DecodeError>
where Self: Sized,

Decodes an instance of the message from a buffer, and merges it into self. Read more
source§

fn merge_length_delimited(&mut self, buf: impl Buf) -> Result<(), DecodeError>
where Self: Sized,

Decodes a length-delimited instance of the message from buffer, and merges it into self.
source§

impl PartialEq for Metric

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for Metric

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

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> 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§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
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> FutureExt for T

source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
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<T> ToOwned for T
where T: Clone,

§

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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,