Skip to content

Commit

Permalink
Fix race condition when initializing metrics for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
khvzak committed Jun 7, 2024
1 parent 27d190d commit 41c7438
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions casper-server/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@ pub fn init(config: &Config) {

#[inline]
pub fn global() -> &'static OpenTelemetryMetrics {
#[cfg(test)]
if METRICS.get().is_none() {
init(&Config::default());
if cfg!(test) {
return METRICS.get_or_init(|| OpenTelemetryMetrics::new(&Config::default()));
}

METRICS.get().unwrap()
}

Expand Down

0 comments on commit 41c7438

Please sign in to comment.