Skip to main content

declare_metrics

Macro declare_metrics 

Source
macro_rules! declare_metrics {
    ($(
        $(#[$attribute:meta])*
        $visibility:vis static $name:ident: $metric_type:ty = $registration:expr;
    )*) => { ... };
}
Expand description

Declares Prometheus metrics as statics, along with an init_metrics that forces all of them.

A metric is only exported once its LazyLock has been forced, so one that is touched only on a rare code path disappears whenever its process is replaced. Generating the initializer from the declarations themselves means a newly added metric cannot be left out of it.