mirror of
https://github.com/prometheus/prometheus.git
synced 2026-06-04 22:22:39 -04:00
Clear explicit counter reset from OOO samples
This clears the counter reset header from the first chunk as well Added / updated unit tests Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
This commit is contained in:
parent
0ea261b33d
commit
80e720a7bf
3 changed files with 23 additions and 11 deletions
|
|
@ -4799,14 +4799,8 @@ func TestOOOHistogramCounterResetHeaders(t *testing.T) {
|
|||
expOOOMmappedChunks{
|
||||
header: chunkenc.UnknownCounterReset,
|
||||
mint: 205,
|
||||
maxt: 205,
|
||||
numSamples: 1,
|
||||
},
|
||||
expOOOMmappedChunks{
|
||||
header: chunkenc.UnknownCounterReset,
|
||||
mint: 210,
|
||||
maxt: 210,
|
||||
numSamples: 1,
|
||||
numSamples: 2,
|
||||
},
|
||||
expOOOMmappedChunks{
|
||||
header: chunkenc.UnknownCounterReset,
|
||||
|
|
@ -4825,7 +4819,7 @@ func TestOOOHistogramCounterResetHeaders(t *testing.T) {
|
|||
|
||||
// One mmapped chunk with (ts, val) [(300, 3000), (301, 3001), (302, 3002), (303, 3003), (350, 4000)].
|
||||
checkOOOExpCounterResetHeader(expOOOMmappedChunks{
|
||||
header: chunkenc.CounterReset,
|
||||
header: chunkenc.UnknownCounterReset,
|
||||
mint: 300,
|
||||
maxt: 350,
|
||||
numSamples: 5,
|
||||
|
|
|
|||
|
|
@ -127,6 +127,11 @@ func (o *OOOChunk) ToEncodedChunks(mint, maxt int64) (chks []memChunk, err error
|
|||
case chunkenc.EncXOR:
|
||||
app.Append(s.t, s.f)
|
||||
case chunkenc.EncHistogram:
|
||||
// Clear explicit counter reset headers in the chunk as we cannot trust
|
||||
// them in OOO.
|
||||
if s.h.CounterResetHint == histogram.CounterReset {
|
||||
s.h.CounterResetHint = histogram.UnknownCounterReset
|
||||
}
|
||||
// Ignoring ok is ok, since we don't want to compare to the wrong previous appender anyway.
|
||||
prevHApp, _ := prevApp.(*chunkenc.HistogramAppender)
|
||||
var (
|
||||
|
|
@ -148,6 +153,11 @@ func (o *OOOChunk) ToEncodedChunks(mint, maxt int64) (chks []memChunk, err error
|
|||
chunk = newChunk
|
||||
}
|
||||
case chunkenc.EncFloatHistogram:
|
||||
// Clear explicit counter reset headers in the chunk as we cannot trust
|
||||
// them in OOO.
|
||||
if s.fh.CounterResetHint == histogram.CounterReset {
|
||||
s.fh.CounterResetHint = histogram.UnknownCounterReset
|
||||
}
|
||||
// Ignoring ok is ok, since we don't want to compare to the wrong previous appender anyway.
|
||||
prevHApp, _ := prevApp.(*chunkenc.FloatHistogramAppender)
|
||||
var (
|
||||
|
|
|
|||
|
|
@ -213,14 +213,22 @@ func TestOOOChunks_ToEncodedChunks(t *testing.T) {
|
|||
},
|
||||
},
|
||||
"has an explicit counter reset": {
|
||||
samples: []sample{
|
||||
{t: 1100, h: h2explicit},
|
||||
},
|
||||
expectedCounterResets: []histogram.CounterResetHint{histogram.UnknownCounterReset},
|
||||
expectedChunks: []chunkVerify{
|
||||
{encoding: chunkenc.EncHistogram, minTime: 1100, maxTime: 1100},
|
||||
},
|
||||
},
|
||||
"has an explicit counter reset inside": {
|
||||
samples: []sample{
|
||||
{t: 1000, h: h1},
|
||||
{t: 1100, h: h2explicit},
|
||||
},
|
||||
expectedCounterResets: []histogram.CounterResetHint{histogram.UnknownCounterReset, histogram.UnknownCounterReset},
|
||||
expectedCounterResets: []histogram.CounterResetHint{histogram.UnknownCounterReset, histogram.NotCounterReset},
|
||||
expectedChunks: []chunkVerify{
|
||||
{encoding: chunkenc.EncHistogram, minTime: 1000, maxTime: 1000},
|
||||
{encoding: chunkenc.EncHistogram, minTime: 1100, maxTime: 1100},
|
||||
{encoding: chunkenc.EncHistogram, minTime: 1000, maxTime: 1100},
|
||||
},
|
||||
},
|
||||
"has a recoded histogram": { // Regression test for wrong minT, maxT in histogram recoding.
|
||||
|
|
|
|||
Loading…
Reference in a new issue