Initialize metrics exporter earlier (fix #389)

This commit is contained in:
Alex Auvolat
2022-09-20 17:45:18 +02:00
parent 7a901f7aab
commit 782630fc27
3 changed files with 15 additions and 5 deletions
+5 -2
View File
@@ -34,7 +34,10 @@ pub struct AdminApiServer {
}
impl AdminApiServer {
pub fn new(garage: Arc<Garage>) -> Self {
pub fn new(
garage: Arc<Garage>,
#[cfg(feature = "metrics")] exporter: PrometheusExporter,
) -> Self {
let cfg = &garage.config.admin;
let metrics_token = cfg
.metrics_token
@@ -47,7 +50,7 @@ impl AdminApiServer {
Self {
garage,
#[cfg(feature = "metrics")]
exporter: opentelemetry_prometheus::exporter().init(),
exporter,
metrics_token,
admin_token,
}