Fix logging of IP addresseses in resolve code. (#548)
authorBrian Brazil <brian.brazil@robustperception.io>
Thu, 7 Nov 2019 11:49:35 +0000 (11:49 +0000)
committerGitHub <noreply@github.com>
Thu, 7 Nov 2019 11:49:35 +0000 (11:49 +0000)
Also add logging missing from one code path.

Signed-off-by: Brian Brazil <brian.brazil@robustperception.io>
prober/utils.go

index eab20044d79e97598c7ce693e7e729e038976708..d1d0388555ccece06750fbc70449ed869c5d1580 100644 (file)
@@ -69,7 +69,7 @@ func chooseProtocol(ctx context.Context, IPProtocol string, fallbackIPProtocol b
                switch IPProtocol {
                case "ip4":
                        if ip.IP.To4() != nil {
-                               level.Info(logger).Log("msg", "Resolved target address", "ip", ip)
+                               level.Info(logger).Log("msg", "Resolved target address", "ip", ip.String())
                                probeIPProtocolGauge.Set(4)
                                return &ip, lookupTime, nil
                        }
@@ -78,9 +78,8 @@ func chooseProtocol(ctx context.Context, IPProtocol string, fallbackIPProtocol b
                        fallback = &ip
 
                case "ip6":
-
                        if ip.IP.To4() == nil {
-                               level.Info(logger).Log("msg", "Resolved target address", "ip", ip)
+                               level.Info(logger).Log("msg", "Resolved target address", "ip", ip.String())
                                probeIPProtocolGauge.Set(6)
                                return &ip, lookupTime, nil
                        }
@@ -101,5 +100,6 @@ func chooseProtocol(ctx context.Context, IPProtocol string, fallbackIPProtocol b
        } else {
                probeIPProtocolGauge.Set(6)
        }
+       level.Info(logger).Log("msg", "Resolved target address", "ip", fallback.String())
        return fallback, lookupTime, nil
 }