From 5a060c27808634a38aace3ba3fe6c5c7d39710f0 Mon Sep 17 00:00:00 2001 From: Chris Cleeland Date: Mon, 22 Apr 2024 13:32:16 -0500 Subject: [PATCH] Fix failing docker test. Don't use a pointer without checking it first. Signed-off-by: Chris Cleeland --- collector/udp_queues_linux.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/collector/udp_queues_linux.go b/collector/udp_queues_linux.go index 104fda39..15beb907 100644 --- a/collector/udp_queues_linux.go +++ b/collector/udp_queues_linux.go @@ -61,7 +61,9 @@ func (c *udpQueuesCollector) Update(ch chan<- prometheus.Metric) error { if errIPv4 == nil { ch <- prometheus.MustNewConstMetric(c.desc, prometheus.GaugeValue, float64(s4.TxQueueLength), "tx", "v4") ch <- prometheus.MustNewConstMetric(c.desc, prometheus.GaugeValue, float64(s4.RxQueueLength), "rx", "v4") - ch <- prometheus.MustNewConstMetric(c.desc, prometheus.GaugeValue, float64(*s4.Drops), "drops", "v4") + if s4.Drops != nil { + ch <- prometheus.MustNewConstMetric(c.desc, prometheus.GaugeValue, float64(*s4.Drops), "drops", "v4") + } } else { if errors.Is(errIPv4, os.ErrNotExist) { c.logger.Debug("not collecting ipv4 based metrics") @@ -74,7 +76,9 @@ func (c *udpQueuesCollector) Update(ch chan<- prometheus.Metric) error { if errIPv6 == nil { ch <- prometheus.MustNewConstMetric(c.desc, prometheus.GaugeValue, float64(s6.TxQueueLength), "tx", "v6") ch <- prometheus.MustNewConstMetric(c.desc, prometheus.GaugeValue, float64(s6.RxQueueLength), "rx", "v6") - ch <- prometheus.MustNewConstMetric(c.desc, prometheus.GaugeValue, float64(*s6.Drops), "drops", "v6") + if s6.Drops != nil { + ch <- prometheus.MustNewConstMetric(c.desc, prometheus.GaugeValue, float64(*s6.Drops), "drops", "v6") + } } else { if errors.Is(errIPv6, os.ErrNotExist) { c.logger.Debug("not collecting ipv6 based metrics")