Skip to content

Commit

Permalink
cleanup style
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgallotta committed Feb 20, 2025
1 parent a753ab6 commit 1dddc98
Showing 1 changed file with 18 additions and 20 deletions.
38 changes: 18 additions & 20 deletions dogstatsd/src/datadog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ impl MetricsIntakeUrlPrefix {

#[inline]
fn from_site(site: Site) -> Self {
Self(format!("https://api.{}", site))
Self(format!("https://api.{site}"))
}
}

Expand Down Expand Up @@ -185,25 +185,23 @@ impl DdApi {
body: Vec<u8>,
content_type: &str,
) -> Result<Response, ShippingError> {
if let Some(client) = &self.client {
let start = std::time::Instant::now();

let resp = client
.post(&url)
.header("DD-API-KEY", &self.api_key)
.header("Content-Type", content_type)
.body(body)
.send()
.await;

let elapsed = start.elapsed();
debug!("Request to {} took {}ms", url, elapsed.as_millis());
resp.map_err(|e| {
ShippingError::Destination(e.status(), format!("Cannot reach {}", url))
})
} else {
Err(ShippingError::Destination(None, "No client".to_string()))
}
let client = &self
.client
.as_ref()
.ok_or_else(|| ShippingError::Destination(None, "No client".to_string()))?;
let start = std::time::Instant::now();

let resp = client
.post(&url)
.header("DD-API-KEY", &self.api_key)
.header("Content-Type", content_type)
.body(body)
.send()
.await;

let elapsed = start.elapsed();
debug!("Request to {} took {}ms", url, elapsed.as_millis());
resp.map_err(|e| ShippingError::Destination(e.status(), format!("Cannot reach {url}")))
}
}

Expand Down

0 comments on commit 1dddc98

Please sign in to comment.