Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mystenmark committed Nov 2, 2022
1 parent c842a48 commit 1cfc38e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions crates/sui-metrics/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ scopeguard = "1"
prometheus = "0.13"
once_cell = "1"
tokio = "1"
tap = "1.0"
8 changes: 6 additions & 2 deletions crates/sui-metrics/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

use once_cell::sync::OnceCell;
use prometheus::{register_int_gauge_vec_with_registry, IntGaugeVec, Registry};
use tap::TapFallible;

use tracing::warn;

pub use scopeguard;

Expand Down Expand Up @@ -36,9 +39,10 @@ impl Metrics {
static METRICS: OnceCell<Metrics> = OnceCell::new();

pub fn init_metrics(registry: &Registry) {
METRICS
let _ = METRICS
.set(Metrics::new(registry))
.expect("sui_metrics::init_metrics duplicate init")
// this happens many times during tests
.tap_err(|_| warn!("init_metrics registry overwritten"));
}

pub fn get_metrics() -> Option<&'static Metrics> {
Expand Down

0 comments on commit 1cfc38e

Please sign in to comment.