Skip to content

Commit

Permalink
fix: handle NaN in scraper (#23944)
Browse files Browse the repository at this point in the history
* fix: handle NaN values in scraper

* chore: a converted int will never be NaN
  • Loading branch information
jeffreyssmith2nd committed Dec 13, 2022
1 parent ade21ad commit ffd069a
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions gather/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,20 @@ func (p *prometheusScraper) parse(r io.Reader, header http.Header, target influx
// summary metric
fields = makeQuantiles(m)
fields["count"] = float64(m.GetSummary().GetSampleCount())
fields["sum"] = float64(m.GetSummary().GetSampleSum())

ss := float64(m.GetSummary().GetSampleSum())
if !math.IsNaN(ss) {
fields["sum"] = ss
}
case dto.MetricType_HISTOGRAM:
// histogram metric
fields = makeBuckets(m)
fields["count"] = float64(m.GetHistogram().GetSampleCount())
fields["sum"] = float64(m.GetHistogram().GetSampleSum())

ss := float64(m.GetHistogram().GetSampleSum())
if !math.IsNaN(ss) {
fields["sum"] = ss
}
default:
// standard metric
fields = getNameAndValue(m)
Expand Down

0 comments on commit ffd069a

Please sign in to comment.