Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
metrics: Don't unwrap client instantiation errors (#18018)
Browse files Browse the repository at this point in the history
(cherry picked from commit 5cc0734)

Co-authored-by: Trent Nelson <trent@solana.com>
  • Loading branch information
mergify[bot] and t-nelson authored Jun 16, 2021
1 parent 4733d6d commit 392d2db
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions metrics/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,23 @@ impl MetricsWriter for InfluxDbMetricsWriter {

let client = reqwest::blocking::Client::builder()
.timeout(Duration::from_secs(5))
.build()
.unwrap();
.build();
let client = match client {
Ok(client) => client,
Err(err) => {
warn!("client instantiation failed: {}", err);
return;
}
};

let response = client.post(write_url.as_str()).body(line).send();
if let Ok(resp) = response {
if !resp.status().is_success() {
warn!(
"submit response unsuccessful: {} {}",
resp.status(),
resp.text().unwrap()
);
let status = resp.status();
if !status.is_success() {
let text = resp
.text()
.unwrap_or_else(|_| "[text body empty]".to_string());
warn!("submit response unsuccessful: {} {}", status, text,);
}
} else {
warn!("submit error: {}", response.unwrap_err());
Expand Down

0 comments on commit 392d2db

Please sign in to comment.