From 6ff620e387527363048c98e59b9db488c15b8d80 Mon Sep 17 00:00:00 2001 From: Ed Schouten Date: Fri, 16 Dec 2016 11:36:36 +0100 Subject: [PATCH] Properly propagate parse errors. --- collector/drbd_linux.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/collector/drbd_linux.go b/collector/drbd_linux.go index 37cbe9cd..a0a2684f 100644 --- a/collector/drbd_linux.go +++ b/collector/drbd_linux.go @@ -177,7 +177,10 @@ func (c *drbdCollector) Update(ch chan<- prometheus.Metric) (err error) { device = fmt.Sprintf("drbd%d", id) } else if metric, ok := drbdNumericalMetrics[kv[0]]; ok { // Numerical value. - value, _ := strconv.ParseFloat(kv[1], 64) + value, err := strconv.ParseFloat(kv[1], 64) + if err != nil { + return err + } ch <- prometheus.MustNewConstMetric( metric.desc, metric.valueType, value*metric.multiplier, device) @@ -199,7 +202,6 @@ func (c *drbdCollector) Update(ch chan<- prometheus.Metric) (err error) { ch <- prometheus.MustNewConstMetric( drbdConnected, prometheus.GaugeValue, connected, device) - } else { log.Infof("Don't know how to process key-value pair [%s: %s]", kv[0], kv[1]) } @@ -207,5 +209,5 @@ func (c *drbdCollector) Update(ch chan<- prometheus.Metric) (err error) { log.Infof("Don't know how to process string %s", field) } } - return nil + return scanner.Err() }