From 4a379b97852f1beef9ca3045bade205a6f20bb2e Mon Sep 17 00:00:00 2001 From: Ruediger Klaehn Date: Mon, 7 Oct 2024 12:58:40 +0100 Subject: [PATCH] Properly handle metrics feature being disabled --- iroh/src/node/builder.rs | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/iroh/src/node/builder.rs b/iroh/src/node/builder.rs index 82b112ab84..289a4779a5 100644 --- a/iroh/src/node/builder.rs +++ b/iroh/src/node/builder.rs @@ -697,26 +697,34 @@ where let client = crate::client::Iroh::new(quic_rpc::RpcClient::new(controller.clone())); let metrics_exporter_handle = if let Some(config) = self.metrics_push_config { - let PushMetricsConfig { - interval, - endpoint: gateway_endpoint, - service_name, - instance_name, - username, - password, - } = config; - let handle = tokio::spawn(async move { - iroh_metrics::service::exporter( - gateway_endpoint, + #[cfg(feature = "metrics")] + { + let PushMetricsConfig { + interval, + endpoint: gateway_endpoint, service_name, instance_name, username, password, - interval, - ) - .await - }); - Some(AbortOnDropHandle::new(handle)) + } = config; + let handle = tokio::spawn(async move { + iroh_metrics::service::exporter( + gateway_endpoint, + service_name, + instance_name, + username, + password, + interval, + ) + .await + }); + Some(AbortOnDropHandle::new(handle)) + } + #[cfg(not(feature = "metrics"))] + { + warn!("Metrics push configuration provided, but metrics feature is not enabled. Ignoring."); + None + } } else { None };