From 41fae74511e9725f77f72d746522e1e877c2e7db Mon Sep 17 00:00:00 2001 From: Yiming Luo Date: Thu, 9 Oct 2025 22:42:56 -0400 Subject: [PATCH] chore: Fix clippy warnings for dogstatsd --- crates/dogstatsd/src/aggregator_service.rs | 12 ++++++------ crates/dogstatsd/src/datadog.rs | 3 +-- crates/dogstatsd/src/flusher.rs | 4 ++-- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/crates/dogstatsd/src/aggregator_service.rs b/crates/dogstatsd/src/aggregator_service.rs index 820351c4..21bb7bc6 100644 --- a/crates/dogstatsd/src/aggregator_service.rs +++ b/crates/dogstatsd/src/aggregator_service.rs @@ -45,11 +45,11 @@ impl AggregatorHandle { let (response_tx, response_rx) = oneshot::channel(); self.tx .send(AggregatorCommand::Flush(response_tx)) - .map_err(|e| format!("Failed to send flush command: {}", e))?; + .map_err(|e| format!("Failed to send flush command: {e}"))?; response_rx .await - .map_err(|e| format!("Failed to receive flush response: {}", e)) + .map_err(|e| format!("Failed to receive flush response: {e}")) } pub async fn get_entry_by_id( @@ -66,11 +66,11 @@ impl AggregatorHandle { timestamp, response_tx, }) - .map_err(|e| format!("Failed to send get_entry_by_id command: {}", e))?; + .map_err(|e| format!("Failed to send get_entry_by_id command: {e}"))?; response_rx .await - .map_err(|e| format!("Failed to receive get_entry_by_id response: {}", e)) + .map_err(|e| format!("Failed to receive get_entry_by_id response: {e}")) } pub fn shutdown(&self) -> Result<(), mpsc::error::SendError> { @@ -125,7 +125,7 @@ impl AggregatorService { distributions, }; - if let Err(_) = response_tx.send(response) { + if response_tx.send(response).is_err() { error!("Failed to send flush response - receiver dropped"); } } @@ -138,7 +138,7 @@ impl AggregatorService { } => { let entry = self.aggregator.get_entry_by_id(name, &tags, timestamp); let response = entry.cloned(); - if let Err(_) = response_tx.send(response) { + if response_tx.send(response).is_err() { error!("Failed to send get_entry_by_id response - receiver dropped"); } } diff --git a/crates/dogstatsd/src/datadog.rs b/crates/dogstatsd/src/datadog.rs index 7e1401e9..f59d1915 100644 --- a/crates/dogstatsd/src/datadog.rs +++ b/crates/dogstatsd/src/datadog.rs @@ -272,8 +272,7 @@ impl DdApi { // handle if status code missing like timeout return Err(ShippingError::Destination( status, - format!("Failed to send request after {} attempts", max_attempts) - .to_string(), + format!("Failed to send request after {attempts} attempts").to_string(), )); } RetryStrategy::LinearBackoff(_, delay) => { diff --git a/crates/dogstatsd/src/flusher.rs b/crates/dogstatsd/src/flusher.rs index b523a931..5dd2540e 100644 --- a/crates/dogstatsd/src/flusher.rs +++ b/crates/dogstatsd/src/flusher.rs @@ -59,7 +59,7 @@ impl Flusher { self.https_proxy.clone(), self.timeout, self.retry_strategy.clone(), - self.compression_level.clone(), + self.compression_level, )), None => { error!("Failed to create dd_api: failed to get API key"); @@ -212,7 +212,7 @@ async fn should_try_next_batch(resp: Result) -> (bool, Err(ShippingError::Destination(sc, msg)) => { // Check if status code indicates a permanent error let is_permanent_error = - sc.map_or(false, |code| code.as_u16() >= 400 && code.as_u16() < 500); + sc.is_some_and(|code| code.as_u16() >= 400 && code.as_u16() < 500); error!("Error shipping data: {:?} {}", sc, msg);