mirror of
https://github.com/prometheus/prometheus.git
synced 2025-12-02 08:01:35 +01:00
promql: Ensure that rate/increase/delta of histograms results in a gauge histogram. (#17608)
Signed-off-by: Andrew Hall <andrew.hall@grafana.com>
This commit is contained in:
parent
e7999528fa
commit
7bb95d548c
@ -400,6 +400,7 @@ func histogramRate(points []HPoint, isCounter bool, metricName string, pos posra
|
||||
annos.Add(annotations.NewNativeHistogramNotGaugeWarning(metricName, pos))
|
||||
}
|
||||
|
||||
h.CounterResetHint = histogram.GaugeType
|
||||
return h.Compact(0), annos
|
||||
}
|
||||
|
||||
|
||||
@ -19,8 +19,23 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/prometheus/prometheus/model/histogram"
|
||||
"github.com/prometheus/prometheus/promql/parser/posrange"
|
||||
)
|
||||
|
||||
func TestHistogramRateCounterResetHint(t *testing.T) {
|
||||
points := []HPoint{
|
||||
{T: 0, H: &histogram.FloatHistogram{CounterResetHint: histogram.CounterReset, Count: 5, Sum: 5}},
|
||||
{T: 1, H: &histogram.FloatHistogram{CounterResetHint: histogram.UnknownCounterReset, Count: 10, Sum: 10}},
|
||||
}
|
||||
fh, _ := histogramRate(points, false, "foo", posrange.PositionRange{})
|
||||
require.Equal(t, histogram.GaugeType, fh.CounterResetHint)
|
||||
|
||||
fh, _ = histogramRate(points, true, "foo", posrange.PositionRange{})
|
||||
require.Equal(t, histogram.GaugeType, fh.CounterResetHint)
|
||||
}
|
||||
|
||||
func TestKahanSumInc(t *testing.T) {
|
||||
testCases := map[string]struct {
|
||||
first float64
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user