diff --git a/metrics/src/metrics.rs b/metrics/src/metrics.rs index 4484e8220..6d55b89e7 100644 --- a/metrics/src/metrics.rs +++ b/metrics/src/metrics.rs @@ -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());