From: Brian Brazil Date: Thu, 7 Nov 2019 11:49:35 +0000 (+0000) Subject: Fix logging of IP addresseses in resolve code. (#548) X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=9935abb9a5ad75bf18e96a5b2b35b4e079948969;p=blackbox_exporter.git Fix logging of IP addresseses in resolve code. (#548) Also add logging missing from one code path. Signed-off-by: Brian Brazil --- diff --git a/prober/utils.go b/prober/utils.go index eab2004..d1d0388 100644 --- a/prober/utils.go +++ b/prober/utils.go @@ -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 }