Skip to content

Commit

Permalink
Merge pull request #28 from Mxinhu/master
Browse files Browse the repository at this point in the history
解决value带有Nan,+Inf和-Inf的metric
  • Loading branch information
UlricQin authored Nov 2, 2021
2 parents 040aa6b + 2001147 commit 5154de3
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions collector/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,18 @@ func Parse(buf []byte) ([]*dataobj.MetricValue, error) {
if err != nil {
return nil, fmt.Errorf("reading text format failed: %s", err)
}

now = time.Now().Unix()
// read metrics
for basename, mf := range metricFamilies {

metrics := []*dataobj.MetricValue{}
for _, m := range mf.Metric {
// 丢弃value中带有Nan,+Inf和-Inf的metric
gv := m.Gauge.GetValue()
if math.IsInf(gv, 0) || math.IsNaN(gv) {
continue
}
// pass ignore metric
if filterIgnoreMetric(basename) {
continue
Expand Down

0 comments on commit 5154de3

Please sign in to comment.