Expand description

Metric recency.

Recency deals with the concept of removing metrics that have not been updated for a certain amount of time. In some use cases, metrics are tied to specific labels which are short-lived, such as labels referencing a date or a version of software. When these labels change, exporters may still be emitting those older metrics which are no longer relevant. In many cases, a long-lived application could continue tracking metrics such that the unique number of metrics grows until a significant portion of memory is required to track them all, even if the majority of them are no longer used.

This module contains the building blocks to both track recency and act on it.

Generation, Generational<T>, and GenerationalPrimitives

These three types form the basis of wrapping metrics so that they can be tracked with a generation counter. This counter is incremented every time a mutating operation is performed. In tracking the generation of a metric, it can be determined whether or not a metric has changed between two observations, even if the value of the metric is identical between the two observations.

Recency

This type provides the tracking of metrics, and their generations, so that exporters can quickly determine if a metric that has just been observed has been “idle” for a given amount of time or longer. This provides the final piece that allows exporters to remove metrics which are no longer relevant to the application.

Structs

The generation of a metric.

Generation tracking for a metric.

Primitives for tracking the generation of metrics.

Tracks recency of metric updates by their registry generation and time.