From 3c62d3c007e501560760e40f86b8b89e31626093 Mon Sep 17 00:00:00 2001 From: Kushagra Udai Date: Wed, 20 Nov 2024 11:11:51 -0800 Subject: [PATCH] Fix lints --- src/lib.rs | 8 ++++++-- src/metrics.rs | 4 +++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index b247529..f465cb0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -28,7 +28,10 @@ SOFTWARE. #![deny(missing_docs)] use http_body_util::BodyExt; + +#[cfg(feature = "metrics")] use metrics::MetricInfoWrapper; + use std::collections::HashMap; use std::convert::Infallible; use std::time::Duration; @@ -770,7 +773,7 @@ impl Consul { req: http::request::Builder, body: BoxBody, duration: Option, - function: Function, + _function: Function, ) -> Result<(Box, u64)> { let req = req .header( @@ -782,13 +785,14 @@ impl Consul { #[cfg(feature = "trace")] let mut span = crate::hyper_wrapper::span_for_request(&self.tracer, &req); + #[cfg(feature = "metrics")] let method = req.method().clone(); let future = self.https_client.request(req); #[cfg(feature = "metrics")] let mut metrics_info_wrapper = - MetricInfoWrapper::new(method.into(), function, None, self.metrics_tx.clone()); + MetricInfoWrapper::new(method.into(), _function, None, self.metrics_tx.clone()); let response = if let Some(dur) = duration { match timeout(dur, future).await { Ok(resp) => resp.map_err(ConsulError::ResponseError), diff --git a/src/metrics.rs b/src/metrics.rs index e5ace95..2413da1 100644 --- a/src/metrics.rs +++ b/src/metrics.rs @@ -1,5 +1,7 @@ -use http::StatusCode; +#[cfg(feature = "metrics")] use std::time::Duration; +#[cfg(feature = "metrics")] +use http::StatusCode; /// A struct to hold information about a calls to consul for metrics. #[cfg(feature = "metrics")]