use std::collections::HashMap;
use std::sync::Mutex;
use lazy_static::lazy_static;
lazy_static! {
static ref GENERIC_METRICS: Mutex<HashMap<String, f64>> = Mutex::new(HashMap::new());
}
pub fn register_metric(name: &str, value: f64) {
let mut metrics = GENERIC_METRICS.lock().unwrap();
metrics.insert(name.to_string(), value);
}
pub fn get_generic_metrics() -> HashMap<String, f64> {
let metrics = GENERIC_METRICS.lock().unwrap();
metrics.clone()
}
pub fn include_generic_metrics(output: &mut String) {
let metrics = GENERIC_METRICS.lock().unwrap();
for (key, value) in metrics.iter() {
output.push_str(&format!("{} {}\n", key, value));
}
}