Replace lazy_static! with LazyLock (#6189)

* Replace `lazy_static` with `LazyLock`.

* Merge branch 'unstable' into remove-lazy-static

# Conflicts:
#	beacon_node/lighthouse_network/src/peer_manager/mod.rs

* Lint fixes.

* Merge branch 'unstable' into remove-lazy-static

# Conflicts:
#	beacon_node/beacon_chain/src/metrics.rs

* Moar lint fixes.

* Update rust version to 1.80.0.

* Merge branch 'unstable' into remove-lazy-static
This commit is contained in:
Jimmy Chen
2024-07-29 21:42:31 +10:00
committed by GitHub
parent 00038dae81
commit 96b00ef66c
85 changed files with 3512 additions and 2370 deletions

View File

@@ -1,32 +1,36 @@
//! Exposes [`MetricsLayer`]: A tracing layer that registers metrics of logging events.
use lazy_static::lazy_static;
use lighthouse_metrics as metrics;
use std::sync::LazyLock;
use tracing_log::NormalizeEvent;
lazy_static! {
/// Count of `INFO` logs registered per enabled dependency.
pub static ref DEP_INFOS_TOTAL: metrics::Result<metrics::IntCounterVec> =
/// Count of `INFO` logs registered per enabled dependency.
pub static DEP_INFOS_TOTAL: LazyLock<metrics::Result<metrics::IntCounterVec>> =
LazyLock::new(|| {
metrics::try_create_int_counter_vec(
"dep_info_total",
"Count of infos logged per enabled dependency",
&["target"]
);
/// Count of `WARN` logs registered per enabled dependency.
pub static ref DEP_WARNS_TOTAL: metrics::Result<metrics::IntCounterVec> =
&["target"],
)
});
/// Count of `WARN` logs registered per enabled dependency.
pub static DEP_WARNS_TOTAL: LazyLock<metrics::Result<metrics::IntCounterVec>> =
LazyLock::new(|| {
metrics::try_create_int_counter_vec(
"dep_warn_total",
"Count of warns logged per enabled dependency",
&["target"]
);
/// Count of `ERROR` logs registered per enabled dependency.
pub static ref DEP_ERRORS_TOTAL: metrics::Result<metrics::IntCounterVec> =
&["target"],
)
});
/// Count of `ERROR` logs registered per enabled dependency.
pub static DEP_ERRORS_TOTAL: LazyLock<metrics::Result<metrics::IntCounterVec>> =
LazyLock::new(|| {
metrics::try_create_int_counter_vec(
"dep_error_total",
"Count of errors logged per enabled dependency",
&["target"]
);
}
&["target"],
)
});
/// Layer that registers Prometheus metrics for `INFO`, `WARN` and `ERROR` logs emitted per dependency.
/// Dependencies are enabled via the `RUST_LOG` env flag.