PrometheusMetricsBuilder consumes Registry not allowing to pass default prometheus registry.
This prevents usage of very convinient lazy static metrics from prometheus package
// This will register to prometheus::default_registry()
lazy_static! {
static ref HIGH_FIVE_COUNTER: IntCounter =
register_int_counter!("highfives", "Number of high fives received").unwrap();
}
// ...
let prometheus = PrometheusMetricsBuilder::new("api")
.endpoint("/metrics")
.registry(prometheus::default_registry()) // <<<<<<<<<<<<<<<<<<<<<< ERROR
.build()
.map_err(|e| RunServiceError::Prometheus(e.to_string()))?;
Though, from the first glance it should be perfectly possible to accept registry by reference instead
PrometheusMetricsBuilder consumes Registry not allowing to pass default prometheus registry. This prevents usage of very convinient lazy static metrics from prometheus package
Though, from the first glance it should be perfectly possible to accept registry by reference instead