mirror of
https://github.com/prometheus/prometheus.git
synced 2025-02-02 08:31:11 -08:00
Fixes/cleanups to renderView() samples truncation.
This commit is contained in:
parent
05504d3642
commit
9b8c671ec9
|
@ -96,15 +96,8 @@ type SamplePair struct {
|
||||||
Timestamp time.Time
|
Timestamp time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s SamplePair) Equal(o SamplePair) (equal bool) {
|
func (s SamplePair) Equal(o SamplePair) bool {
|
||||||
switch {
|
return s.Value.Equal(o.Value) && s.Timestamp.Equal(o.Timestamp)
|
||||||
case !s.Value.Equal(o.Value):
|
|
||||||
return
|
|
||||||
case !s.Timestamp.Equal(o.Timestamp):
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type Values []SamplePair
|
type Values []SamplePair
|
||||||
|
@ -158,7 +151,7 @@ func (v Values) TruncateBefore(t time.Time) (values Values) {
|
||||||
index := sort.Search(len(v), func(i int) bool {
|
index := sort.Search(len(v), func(i int) bool {
|
||||||
timestamp := v[i].Timestamp
|
timestamp := v[i].Timestamp
|
||||||
|
|
||||||
return timestamp.After(t) || timestamp.Equal(t)
|
return !timestamp.Before(t)
|
||||||
})
|
})
|
||||||
|
|
||||||
switch index {
|
switch index {
|
||||||
|
|
|
@ -417,13 +417,13 @@ func (t *tieredStorage) renderView(viewJob viewJob) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
chunk = chunk.TruncateBefore(targetTime)
|
||||||
|
|
||||||
lastChunkTime := chunk[len(chunk)-1].Timestamp
|
lastChunkTime := chunk[len(chunk)-1].Timestamp
|
||||||
if lastChunkTime.After(targetTime) {
|
if lastChunkTime.After(targetTime) {
|
||||||
targetTime = lastChunkTime
|
targetTime = lastChunkTime
|
||||||
}
|
}
|
||||||
|
|
||||||
chunk = chunk.TruncateBefore(targetTime)
|
|
||||||
|
|
||||||
// For each op, extract all needed data from the current chunk.
|
// For each op, extract all needed data from the current chunk.
|
||||||
out := model.Values{}
|
out := model.Values{}
|
||||||
for _, op := range standingOps {
|
for _, op := range standingOps {
|
||||||
|
|
Loading…
Reference in a new issue