Fix validate that string is not empty before strconv.ParseFloat (#59)

Thanks. I could have sworn I went through already and done this at one point in time, but I guess not.
This commit is contained in:
Jesus Rafael Carrillo
2019-12-02 19:01:36 -08:00
committed by Steve Brunton
parent 5cccba9e17
commit 9ceb56fdbf
8 changed files with 30 additions and 10 deletions

View File

@@ -54,7 +54,7 @@ func (c *resourceCollector) collect(ctx *collectorContext) error {
}
for _, re := range stats {
c.collectForStat(re, ctx)
c.collectForStat(re, ctx)
}
return nil
@@ -82,8 +82,8 @@ func (c *resourceCollector) collectForStat(re *proto.Sentence, ctx *collectorCon
func (c *resourceCollector) collectMetricForProperty(property string, re *proto.Sentence, ctx *collectorContext) {
var v float64
var err error
// const boardname = "BOARD"
// const version = "3.33.3"
// const boardname = "BOARD"
// const version = "3.33.3"
boardname := re.Map["board-name"]
version := re.Map["version"]
@@ -91,6 +91,9 @@ func (c *resourceCollector) collectMetricForProperty(property string, re *proto.
if property == "uptime" {
v, err = parseUptime(re.Map[property])
} else {
if re.Map[property] == "" {
return
}
v, err = strconv.ParseFloat(re.Map[property], 64)
}