Skip to content

Commit

Permalink
More logs
Browse files Browse the repository at this point in the history
  • Loading branch information
hczhu-db committed Aug 7, 2024
1 parent d598a35 commit 50fd421
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
16 changes: 14 additions & 2 deletions pkg/dedup/iter.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ type dedupSeries struct {
}

func newDedupSeries(lset labels.Labels, replicas []storage.Series, f string) *dedupSeries {
debug("dedup for a counter? %v", isCounter(f))
return &dedupSeries{lset: lset, isCounter: isCounter(f), replicas: replicas, f: f}
}

Expand All @@ -203,17 +204,18 @@ func (s *dedupSeries) Labels() labels.Labels {
}

func (s *dedupSeries) Iterator(_ chunkenc.Iterator) chunkenc.Iterator {
debug("Iterator() of length %v", len(s.replicas))
var it adjustableSeriesIterator
if s.isCounter {
it = &counterErrAdjustSeriesIterator{Iterator: s.replicas[0].Iterator(nil)}
it = newCounterErrAdjustSeriesIterator(s.replicas[0].Iterator(nil))
} else {
it = noopAdjustableSeriesIterator{Iterator: s.replicas[0].Iterator(nil)}
}

for _, o := range s.replicas[1:] {
var replicaIter adjustableSeriesIterator
if s.isCounter {
replicaIter = &counterErrAdjustSeriesIterator{Iterator: o.Iterator(nil)}
replicaIter = newCounterErrAdjustSeriesIterator(o.Iterator(nil))
} else {
replicaIter = noopAdjustableSeriesIterator{Iterator: o.Iterator(nil)}
}
Expand Down Expand Up @@ -265,6 +267,15 @@ type counterErrAdjustSeriesIterator struct {
chunkenc.Iterator

errAdjust float64

id int
}

var gId int

func newCounterErrAdjustSeriesIterator(itr chunkenc.Iterator) *counterErrAdjustSeriesIterator {
gId++
return &counterErrAdjustSeriesIterator{Iterator: itr, id: gId}
}

func (it *counterErrAdjustSeriesIterator) adjustAtValue(lastFloatValue float64) {
Expand All @@ -277,6 +288,7 @@ func (it *counterErrAdjustSeriesIterator) adjustAtValue(lastFloatValue float64)

func (it *counterErrAdjustSeriesIterator) At() (int64, float64) {
t, v := it.Iterator.At()
debug(" one replica original value #%d: %v %v", it.id, t/1000, v)
return t, v + it.errAdjust
}

Expand Down
5 changes: 4 additions & 1 deletion pkg/query/iter.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
package query

import (
"fmt"

"github.com/pkg/errors"
"github.com/prometheus/prometheus/model/histogram"
"github.com/prometheus/prometheus/model/labels"
Expand Down Expand Up @@ -46,8 +48,8 @@ func (s *promSeriesSet) At() storage.Series {
if s.set.Err() != nil {
return nil
}

currLset, currChunks := s.set.At()
fmt.Printf("merge_itr: promSeriesSet.At() %v %v %v %v %v %v\n", currLset.Hash(), currLset, currChunks, s.mint, s.maxt, s.aggrs)
return newChunkSeries(currLset, currChunks, s.mint, s.maxt, s.aggrs)
}

Expand Down Expand Up @@ -83,6 +85,7 @@ func (*storeSeriesSet) Err() error {
}

func (s *storeSeriesSet) At() (labels.Labels, []storepb.AggrChunk) {
fmt.Printf("merge_itr: storeSeriesSet.At() %v %v\n", s.series[s.i].Labels, s.series[s.i].Chunks)
return s.series[s.i].PromLabels(), s.series[s.i].Chunks
}

Expand Down

0 comments on commit 50fd421

Please sign in to comment.