use prometheus::{Encoder, Registry, TextEncoder};
#[cfg(feature = "prometheus")]
pub fn create_prometheus_registry() -> Registry {
Registry::new()
}
#[cfg(feature = "prometheus")]
pub fn get_metrics_as_string(registry: &Registry) -> String {
let mut buffer = Vec::new();
let encoder = TextEncoder::new();
let metric_families = registry.gather();
encoder.encode(&metric_families, &mut buffer).unwrap();
String::from_utf8(buffer).unwrap()
}
#[cfg(not(feature = "prometheus"))]
pub fn create_prometheus_registry() -> () {}
#[cfg(not(feature = "prometheus"))]
pub fn get_metrics_as_string(_registry: &()) -> String {
"Prometheus metrics export is disabled (feature not enabled)".to_string()
}