add prober_dns_lookup_time_seconds metric to solve #60 (#118)
authoraparcar <spooren@informatik.uni-leipzig.de>
Thu, 2 Mar 2017 00:45:51 +0000 (01:45 +0100)
committerBrian Brazil <brian-brazil@users.noreply.github.com>
Thu, 2 Mar 2017 00:45:51 +0000 (00:45 +0000)
add probe_dns_lookup_time_seconds metric

icmp.go

diff --git a/icmp.go b/icmp.go
index 57fa0a10ad05f03db3b27d286cc8581b7612b530..0d5124a7c1126502283e2995fcc4c6296681eb04 100644 (file)
--- a/icmp.go
+++ b/icmp.go
@@ -73,10 +73,13 @@ func probeICMP(target string, w http.ResponseWriter, module Module) (success boo
                fallbackProtocol = "ip6"
        }
 
+       resolveStart := time.Now()
        ip, err := net.ResolveIPAddr(module.ICMP.PreferredIpProtocol, target)
        if err != nil && fallbackProtocol != "" {
                ip, err = net.ResolveIPAddr(fallbackProtocol, target)
        }
+       fmt.Fprintf(w, "probe_dns_lookup_time_seconds %f\n", float64(time.Since(resolveStart).Seconds()))
+
        if err != nil {
                log.Errorf("Error resolving address %s: %s", target, err)
                return