Only record elapsed if its not 0

This commit is contained in:
Jeremy Wall 2021-01-05 21:56:51 -05:00
parent 301bbe14fe
commit 76a5006a1f

View File

@ -66,18 +66,21 @@ pub fn start_echo_loop(
.send_with_timeout(MAXHOPS.flag, Some(Duration::from_millis(PINGTIMEOUT.flag))) { .send_with_timeout(MAXHOPS.flag, Some(Duration::from_millis(PINGTIMEOUT.flag))) {
Ok(r) => match r { Ok(r) => match r {
EkkoResponse::DestinationResponse(r) => { EkkoResponse::DestinationResponse(r) => {
let elapsed = r.elapsed.as_millis();
info!( info!(
"ICMP: Reply from {}: time={}ms", "ICMP: Reply from {}: time={}ms",
r.address.unwrap(), r.address.unwrap(),
r.elapsed.as_millis(), elapsed,
); );
ping_counter ping_counter
.with(&prometheus::labels! {"result" => "ok", "domain" => domain_name}) .with(&prometheus::labels! {"result" => "ok", "domain" => domain_name})
.inc(); .inc();
if elapsed != 0 {
ping_latency_guage ping_latency_guage
.with(&prometheus::labels! {"domain" => domain_name}) .with(&prometheus::labels! {"domain" => domain_name})
.set(r.elapsed.as_millis() as i64); .set(r.elapsed.as_millis() as i64);
} }
}
EkkoResponse::UnreachableResponse((_, ref _code)) => { EkkoResponse::UnreachableResponse((_, ref _code)) => {
// If we got unreachable we need to set up a new sender. // If we got unreachable we need to set up a new sender.
error!("{:?}", r); error!("{:?}", r);