promql: Add a guard against a nil histogram in sum aggregation
This can happen if the aggregation starts with a float and later encounters a histogram. In that case, the newly encountered histogram would have been added to a nil histogram. This should be tested, of course, but that's best done within the PromQL testing framework, which we still need to enable for histograms (for which we have a TODO in the code and now also a card in the GH project). Signed-off-by: beorn7 <beorn@grafana.com>
This commit is contained in:
parent
6f33ab2b35
commit
53ca375345
|
@ -2321,7 +2321,12 @@ func (ev *evaluator) aggregation(op parser.ItemType, grouping []string, without
|
||||||
case parser.SUM:
|
case parser.SUM:
|
||||||
if s.H != nil {
|
if s.H != nil {
|
||||||
group.hasHistogram = true
|
group.hasHistogram = true
|
||||||
|
if group.histogramValue != nil {
|
||||||
group.histogramValue.Add(s.H)
|
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 {
|
} else {
|
||||||
group.hasFloat = true
|
group.hasFloat = true
|
||||||
group.value += s.V
|
group.value += s.V
|
||||||
|
|
Loading…
Reference in New Issue