fedimintd/fedimintd/
metrics.rs

1use std::sync::LazyLock;
2
3use fedimint_metrics::prometheus::{IntGaugeVec, register_int_gauge_vec_with_registry};
4use fedimint_metrics::{REGISTRY, opts};
5
6// Note: we can't really use a counter for monitoring restarts of the
7// application because such timer would always equal 1, and Prometheus would
8// never actually add it up. But what we can do is to use a gauge with a
9// timestamp, and then detect every time it changes.
10pub(crate) static APP_START_TS: LazyLock<IntGaugeVec> = LazyLock::new(|| {
11    register_int_gauge_vec_with_registry!(
12        opts!(
13            "app_start_ts",
14            "Unix timestamp of the application time with version labels"
15        ),
16        &["version", "version_hash"],
17        REGISTRY
18    )
19    .unwrap()
20});