Skip to content

Commit ecf14b8

Browse files
committed
Fix failing docker test.
Don't use a pointer without checking it first. Signed-off-by: Chris Cleeland <[email protected]>
1 parent 6d78a34 commit ecf14b8

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

collector/udp_queues_linux.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ func (c *udpQueuesCollector) Update(ch chan<- prometheus.Metric) error {
6161
if errIPv4 == nil {
6262
ch <- prometheus.MustNewConstMetric(c.desc, prometheus.GaugeValue, float64(s4.TxQueueLength), "tx", "v4")
6363
ch <- prometheus.MustNewConstMetric(c.desc, prometheus.GaugeValue, float64(s4.RxQueueLength), "rx", "v4")
64-
ch <- prometheus.MustNewConstMetric(c.desc, prometheus.GaugeValue, float64(*s4.Drops), "drops", "v4")
64+
if s4.Drops != nil {
65+
ch <- prometheus.MustNewConstMetric(c.desc, prometheus.GaugeValue, float64(*s4.Drops), "drops", "v4")
66+
}
6567
} else {
6668
if errors.Is(errIPv4, os.ErrNotExist) {
6769
c.logger.Debug("not collecting ipv4 based metrics")
@@ -74,7 +76,9 @@ func (c *udpQueuesCollector) Update(ch chan<- prometheus.Metric) error {
7476
if errIPv6 == nil {
7577
ch <- prometheus.MustNewConstMetric(c.desc, prometheus.GaugeValue, float64(s6.TxQueueLength), "tx", "v6")
7678
ch <- prometheus.MustNewConstMetric(c.desc, prometheus.GaugeValue, float64(s6.RxQueueLength), "rx", "v6")
77-
ch <- prometheus.MustNewConstMetric(c.desc, prometheus.GaugeValue, float64(*s6.Drops), "drops", "v6")
79+
if s6.Drops != nil {
80+
ch <- prometheus.MustNewConstMetric(c.desc, prometheus.GaugeValue, float64(*s6.Drops), "drops", "v6")
81+
}
7882
} else {
7983
if errors.Is(errIPv6, os.ErrNotExist) {
8084
c.logger.Debug("not collecting ipv6 based metrics")

0 commit comments

Comments
 (0)