metrics: Don't unwrap client instantiation errors
This commit is contained in:
parent
6f5b248746
commit
5cc073420a
|
@ -103,16 +103,23 @@ impl MetricsWriter for InfluxDbMetricsWriter {
|
||||||
|
|
||||||
let client = reqwest::blocking::Client::builder()
|
let client = reqwest::blocking::Client::builder()
|
||||||
.timeout(Duration::from_secs(5))
|
.timeout(Duration::from_secs(5))
|
||||||
.build()
|
.build();
|
||||||
.unwrap();
|
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();
|
let response = client.post(write_url.as_str()).body(line).send();
|
||||||
if let Ok(resp) = response {
|
if let Ok(resp) = response {
|
||||||
if !resp.status().is_success() {
|
let status = resp.status();
|
||||||
warn!(
|
if !status.is_success() {
|
||||||
"submit response unsuccessful: {} {}",
|
let text = resp
|
||||||
resp.status(),
|
.text()
|
||||||
resp.text().unwrap()
|
.unwrap_or_else(|_| "[text body empty]".to_string());
|
||||||
);
|
warn!("submit response unsuccessful: {} {}", status, text,);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
warn!("submit error: {}", response.unwrap_err());
|
warn!("submit error: {}", response.unwrap_err());
|
||||||
|
|
Loading…
Reference in New Issue