Skip to main content

EncodeMetric

Trait EncodeMetric 

Source
pub trait EncodeMetric {
    // Required methods
    fn encode(&self, encoder: MetricEncoder<'_>) -> Result<(), Error>;
    fn metric_type(&self) -> MetricType;

    // Provided method
    fn is_empty(&self) -> bool { ... }
}
Expand description

Trait implemented by each metric type, e.g. Counter, to implement its encoding in the OpenMetric text format.

Required Methods§

Source

fn encode(&self, encoder: MetricEncoder<'_>) -> Result<(), Error>

Encode the given instance in the OpenMetrics text encoding.

Source

fn metric_type(&self) -> MetricType

The OpenMetrics metric type of the instance.

Provided Methods§

Source

fn is_empty(&self) -> bool

Check if the metric is empty.

An empty metric is a metric that has no data to encode, and thus should not have any descriptor in the final output.

By default, this returns false, ensuring the metric and its description is always encoded.

Trait Implementations§

Source§

impl EncodeMetric for Box<dyn EncodeMetric>

Source§

fn encode(&self, encoder: MetricEncoder<'_>) -> Result<(), Error>

Encode the given instance in the OpenMetrics text encoding.
Source§

fn metric_type(&self) -> MetricType

The OpenMetrics metric type of the instance.
Source§

fn is_empty(&self) -> bool

Check if the metric is empty. Read more

Implementations on Foreign Types§

Source§

impl EncodeMetric for Box<dyn EncodeMetric>

Source§

fn encode(&self, encoder: MetricEncoder<'_>) -> Result<(), Error>

Source§

fn metric_type(&self) -> MetricType

Implementors§