aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlex <alex@adnab.me>2022-09-20 17:53:46 +0200
committerAlex <alex@adnab.me>2022-09-20 17:53:46 +0200
commitfc8550864898a7a24e71dfb29027fd9b39305eab (patch)
tree56db83c31c53688c7c216cc425d1e2602e5ef1a4 /src
parent7a901f7aab29d9ae09c378e3824b8236458f85f1 (diff)
parent782630fc27b41b9ae58d1417cace2995c99856fc (diff)
downloadgarage-fc8550864898a7a24e71dfb29027fd9b39305eab.tar.gz
garage-fc8550864898a7a24e71dfb29027fd9b39305eab.zip
Merge pull request 'Initialize metrics exporter earlier (fix #389)' (#390) from fix-metrics into main
Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/garage/pulls/390
Diffstat (limited to 'src')
-rw-r--r--src/api/admin/api_server.rs7
-rw-r--r--src/garage/server.rs9
2 files changed, 13 insertions, 3 deletions
diff --git a/src/api/admin/api_server.rs b/src/api/admin/api_server.rs
index fb0078cc..0816bda1 100644
--- a/src/api/admin/api_server.rs
+++ b/src/api/admin/api_server.rs
@@ -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,
}
diff --git a/src/garage/server.rs b/src/garage/server.rs
index aeef02a2..28710a8e 100644
--- a/src/garage/server.rs
+++ b/src/garage/server.rs
@@ -32,6 +32,9 @@ pub async fn run_server(config_file: PathBuf) -> Result<(), Error> {
// ---- Initialize Garage internals ----
+ #[cfg(feature = "metrics")]
+ let metrics_exporter = opentelemetry_prometheus::exporter().init();
+
info!("Initializing background runner...");
let watch_cancel = netapp::util::watch_ctrl_c();
let (background, await_background_done) = BackgroundRunner::new(16, watch_cancel.clone());
@@ -50,7 +53,11 @@ pub async fn run_server(config_file: PathBuf) -> Result<(), Error> {
}
info!("Initialize Admin API server and metrics collector...");
- let admin_server = AdminApiServer::new(garage.clone());
+ let admin_server = AdminApiServer::new(
+ garage.clone(),
+ #[cfg(feature = "metrics")]
+ metrics_exporter,
+ );
info!("Launching internal Garage cluster communications...");
let run_system = tokio::spawn(garage.system.clone().run(watch_cancel.clone()));