fix: handle NaN in scraper (#23944)

* fix: handle NaN values in scraper

* chore: a converted int will never be NaN
pull/23676/head^2
Jeffrey Smith II 2022-12-13 15:58:50 -05:00 committed by GitHub
parent ade21ad9a1
commit ffd069a8a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 2 deletions

View File

@ -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)