Merge pull request #10025 from prometheus/beorn7/histogram-sum

promql: Add a guard against a nil histogram in sum aggregation
This commit is contained in:
Björn Rabenstein 2021-12-15 15:12:40 +01:00 committed by GitHub
commit 7e2fa88a1d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2321,7 +2321,12 @@ func (ev *evaluator) aggregation(op parser.ItemType, grouping []string, without
case parser.SUM:
if s.H != nil {
group.hasHistogram = true
group.histogramValue.Add(s.H)
if group.histogramValue != nil {
group.histogramValue.Add(s.H)
}
// Otherwise the aggregation contained floats
// previously and will be invalid anyway. No
// point in copying the histogram in that case.
} else {
group.hasFloat = true
group.value += s.V