From bc7afb7a17377bf6a4ced10bc3e5a7228b64d383 Mon Sep 17 00:00:00 2001 From: Mikolaj Pawlikowski Date: Wed, 11 Mar 2020 12:35:47 +0000 Subject: [PATCH] Return response time on failure to ping Signed-off-by: Mikolaj Pawlikowski --- pkg/goldpinger/client.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/goldpinger/client.go b/pkg/goldpinger/client.go index 374cbbc..0cda30d 100644 --- a/pkg/goldpinger/client.go +++ b/pkg/goldpinger/client.go @@ -88,13 +88,13 @@ func PingAllPods(pods map[string]string) *models.CheckResults { resp, err := getClient(pickPodHostIP(podIP, hostIP)).Operations.Ping(nil) channelResult.hostIPv4.UnmarshalText([]byte(hostIP)) + responseTime := time.Since(start).Nanoseconds() / int64(time.Millisecond) var OK = (err == nil) if OK { - responseTime := time.Since(start).Nanoseconds() / int64(time.Millisecond) channelResult.podResult = models.PodResult{HostIP: channelResult.hostIPv4, OK: &OK, Response: resp.Payload, StatusCode: 200, ResponseTimeMs: responseTime} timer.ObserveDuration() } else { - channelResult.podResult = models.PodResult{HostIP: channelResult.hostIPv4, OK: &OK, Error: err.Error(), StatusCode: 500} + channelResult.podResult = models.PodResult{HostIP: channelResult.hostIPv4, OK: &OK, Error: err.Error(), StatusCode: 500, ResponseTimeMs: responseTime} CountError("ping") } channelResult.podIP = podIP