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:
committed by
Steve Brunton
parent
5cccba9e17
commit
9ceb56fdbf
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user