A fork of the lighthouse_metrics crate used to implement prometheus
A wrapper around the prometheus
crate that provides a global, lazy_static
metrics registry
and functions to add and use the following components (more info at
Prometheus docs):
Histogram
: used withstart_timer()
andobserve_duration()
orobserve()
method to record durations (e.g., block processing time).IncCounter
: used to represent an ideally ever-growing, never-shrinking integer (e.g., number of block processing requests).IntGauge
: used to represent an varying integer (e.g., number of attestations per block).
Important
Metrics will fail if two items have the same name
. All metrics must have a unique name
.
Because we use a global registry there is no namespace per crate, it's one big global space.
See the Prometheus naming best practices when choosing metric names.
Example
use Lazy;
use *;
// These metrics are "magically" linked to the global registry defined in `lighthouse_metrics`.
pub static RUN_COUNT: = new;
pub static CURRENT_VALUE: = new;
pub static RUN_TIME: = new;