Skip to content

Commit f32a295

Browse files
committed
fix: handle logger.Log error return values in ICMP prober
1 parent f3ac695 commit f32a295

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

internal/prober/icmp/icmp_impl.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,11 @@ func probeICMP(ctx context.Context, target string, module Module, registry *prom
109109
hopLimitGauge.Set(float64(pkt.TTL))
110110
}
111111

112-
logger.Log("level", "info", "msg", "Found matching reply packet", "seq", strconv.Itoa(pkt.Seq))
112+
_ = logger.Log("level", "info", "msg", "Found matching reply packet", "seq", strconv.Itoa(pkt.Seq))
113113
}
114114

115115
pinger.OnDuplicateRecv = func(pkt *ping.Packet) {
116-
logger.Log("level", "info", "msg", "Duplicate packet received", "seq", strconv.Itoa(pkt.Seq))
116+
_ = logger.Log("level", "info", "msg", "Duplicate packet received", "seq", strconv.Itoa(pkt.Seq))
117117
}
118118

119119
pinger.OnFinish = func(stats *ping.Statistics) {
@@ -124,7 +124,7 @@ func probeICMP(ctx context.Context, target string, module Module, registry *prom
124124
durationStddevGauge.Set(stats.StdDevRtt.Seconds())
125125
packetsSentGauge.Set(float64(stats.PacketsSent))
126126
packetsReceivedGauge.Set(float64(stats.PacketsRecv))
127-
logger.Log("level", "info", "msg", "Probe finished", "packets_sent", stats.PacketsSent, "packets_received", stats.PacketsRecv)
127+
_ = logger.Log("level", "info", "msg", "Probe finished", "packets_sent", stats.PacketsSent, "packets_received", stats.PacketsRecv)
128128
}
129129

130130
pinger.SetDoNotFragment(module.ICMP.DontFragment)
@@ -142,10 +142,10 @@ func probeICMP(ctx context.Context, target string, module Module, registry *prom
142142

143143
setupStart = time.Now()
144144

145-
logger.Log("level", "info", "msg", "Creating socket")
145+
_ = logger.Log("level", "info", "msg", "Creating socket")
146146

147147
if err := pinger.RunWithContext(ctx); err != nil {
148-
logger.Log("level", "info", "msg", "failed to run ping", "err", err.Error())
148+
_ = logger.Log("level", "info", "msg", "failed to run ping", "err", err.Error())
149149
return false, 0
150150
}
151151

internal/prober/icmp/utils.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func chooseProtocol(ctx context.Context, ipProtocol string, fallbackIPProtocol b
5858
fallbackProtocol = "ip6"
5959
}
6060

61-
logger.Log("level", "info", "msg", "Resolving target address", "ip_protocol", ipProtocol)
61+
_ = logger.Log("level", "info", "msg", "Resolving target address", "ip_protocol", ipProtocol)
6262
resolveStart := time.Now()
6363

6464
defer func() {
@@ -73,13 +73,13 @@ func chooseProtocol(ctx context.Context, ipProtocol string, fallbackIPProtocol b
7373
ips, err := resolver.LookupIP(ctx, ipProtocol, target)
7474
if err == nil {
7575
for _, ip := range ips {
76-
logger.Log("level", "info", "msg", "Resolved target address", "ip", ip.String())
76+
_ = logger.Log("level", "info", "msg", "Resolved target address", "ip", ip.String())
7777
probeIPProtocolGauge.Set(protocolToGauge[ipProtocol])
7878
probeIPAddrHash.Set(ipHash(ip))
7979
return &net.IPAddr{IP: ip}, lookupTime, nil
8080
}
8181
}
82-
logger.Log("level", "warn", "msg", "Resolution with IP protocol failed", "err", err)
82+
_ = logger.Log("level", "warn", "msg", "Resolution with IP protocol failed", "err", err)
8383

8484
if isRetryableError(err) {
8585
continue
@@ -90,7 +90,7 @@ func chooseProtocol(ctx context.Context, ipProtocol string, fallbackIPProtocol b
9090

9191
ips, err := resolver.LookupIPAddr(ctx, target)
9292
if err != nil {
93-
logger.Log("level", "warn", "msg", "Resolution with IP protocol failed", "err", err)
93+
_ = logger.Log("level", "warn", "msg", "Resolution with IP protocol failed", "err", err)
9494

9595
if isRetryableError(err) {
9696
continue
@@ -105,7 +105,7 @@ func chooseProtocol(ctx context.Context, ipProtocol string, fallbackIPProtocol b
105105
switch ipProtocol {
106106
case "ip4":
107107
if ip.IP.To4() != nil {
108-
logger.Log("level", "info", "msg", "Resolved target address", "ip", ip.String())
108+
_ = logger.Log("level", "info", "msg", "Resolved target address", "ip", ip.String())
109109
probeIPProtocolGauge.Set(4)
110110
probeIPAddrHash.Set(ipHash(ip.IP))
111111
return &ip, lookupTime, nil
@@ -116,7 +116,7 @@ func chooseProtocol(ctx context.Context, ipProtocol string, fallbackIPProtocol b
116116

117117
case "ip6":
118118
if ip.IP.To4() == nil {
119-
logger.Log("level", "info", "msg", "Resolved target address", "ip", ip.String())
119+
_ = logger.Log("level", "info", "msg", "Resolved target address", "ip", ip.String())
120120
probeIPProtocolGauge.Set(6)
121121
probeIPAddrHash.Set(ipHash(ip.IP))
122122
return &ip, lookupTime, nil
@@ -129,7 +129,7 @@ func chooseProtocol(ctx context.Context, ipProtocol string, fallbackIPProtocol b
129129

130130
// Unable to find ip and no fallback set.
131131
if fallbackIdx == -1 || !fallbackIPProtocol {
132-
logger.Log("level", "error", "msg", "unable to find ip; no fallback")
132+
_ = logger.Log("level", "error", "msg", "unable to find ip; no fallback")
133133
break
134134
}
135135

@@ -141,7 +141,7 @@ func chooseProtocol(ctx context.Context, ipProtocol string, fallbackIPProtocol b
141141
}
142142
fallback := ips[fallbackIdx]
143143
probeIPAddrHash.Set(ipHash(fallback.IP))
144-
logger.Log("level", "info", "msg", "Resolved target address", "ip", fallback.String())
144+
_ = logger.Log("level", "info", "msg", "Resolved target address", "ip", fallback.String())
145145
return &fallback, lookupTime, nil
146146
}
147147

0 commit comments

Comments
 (0)