pub struct MetricsEncoder<W: Write> { /* private fields */ }
Expand description

MetricsEncoder provides methods to encode metrics in a text format that can be understood by Prometheus.

Metrics are encoded with the block time included, to allow Prometheus to discard out-of-order samples collected from replicas that are behind.

See Exposition Formats for an informal specification of the text format.

Implementations§

Constructs a new encoder dumping metrics with the given timestamp into the specified writer.

Returns the internal buffer that was used to record the metrics.

Encodes the metadata and the value of a histogram.

SUM is the sum of all observed values, before they were put into buckets.

BUCKETS is a list (key, value) pairs, where KEY is the bucket and VALUE is the number of items in this bucket (i.e., it’s not a cumulative value).

Encodes the metadata and the value of a counter.

Panics

This function panics if the name argument does not match pattern [a-zA-Z_][a-zA-Z0-9_].

Encodes the metadata and the value of a gauge.

Panics

This function panics if the name argument does not match pattern [a-zA-Z_][a-zA-Z0-9_].

Starts encoding of a counter that uses labels.

Panics

This function panics if the name argument does not match pattern [a-zA-Z_][a-zA-Z0-9_].

Starts encoding of a gauge that uses labels.

Panics

This function panics if the name argument does not match pattern [a-zA-Z_][a-zA-Z0-9_].

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.