Refs #50
File: crates/charon-metrics/src/lib.rs
Problem
metrics-exporter-prometheus uses a process-global recorder. PrometheusBuilder::install() panics on second call within the same process. Any test that calls init() twice (or two tests in the same binary) panics. Tests must use serial_test or share a OnceCell.
Fix
Wrap init in OnceCell:
use std::sync::OnceLock;
static INIT: OnceLock<()> = OnceLock::new();
pub fn init(cfg: &MetricsConfig) -> Result<(), MetricsError> {
INIT.get_or_init(|| { /* install recorder */ });
Ok(())
}
Add unit test: init twice does not panic.
Refs #50
File: crates/charon-metrics/src/lib.rs
Problem
metrics-exporter-prometheus uses a process-global recorder. PrometheusBuilder::install() panics on second call within the same process. Any test that calls init() twice (or two tests in the same binary) panics. Tests must use serial_test or share a OnceCell.
Fix
Wrap init in OnceCell:
Add unit test: init twice does not panic.