Skip to content

Commit

Permalink
Fix values chunks_fetched_duration metric
Browse files Browse the repository at this point in the history
This commit fixes the chunks_fetch_duration metric in store gateway.

Signed-off-by: Filip Petkovski <filip.petkovsky@gmail.com>
  • Loading branch information
fpetkovski committed Dec 8, 2022
1 parent e6f0b6e commit 9ee1a5d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pkg/store/bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,7 @@ func (b *blockSeriesClient) Recv() (*storepb.SeriesResponse, error) {

if len(b.entries) == 0 {
if b.chunkr != nil {
b.chunkFetchDuration.Observe(float64(b.chunkr.stats.ChunksFetchDurationSum))
b.chunkFetchDuration.Observe(b.chunkr.stats.ChunksFetchDurationSum.Seconds())
}
return nil, io.EOF
}
Expand Down Expand Up @@ -2790,6 +2790,9 @@ func (r *bucketChunkReader) load(ctx context.Context, res []seriesEntry, aggrs [
// This data range covers chunks starting at supplied offsets.
func (r *bucketChunkReader) loadChunks(ctx context.Context, res []seriesEntry, aggrs []storepb.Aggr, seq int, part Part, pIdxs []loadIdx, calculateChunkChecksum bool, bytesLimiter BytesLimiter) error {
fetchBegin := time.Now()
defer func() {
r.stats.ChunksFetchDurationSum += time.Since(fetchBegin)
}()

// Get a reader for the required range.
reader, err := r.block.chunkRangeReader(ctx, seq, int64(part.Start), int64(part.End-part.Start))
Expand All @@ -2810,7 +2813,6 @@ func (r *bucketChunkReader) loadChunks(ctx context.Context, res []seriesEntry, a

r.stats.chunksFetchCount++
r.stats.chunksFetched += len(pIdxs)
r.stats.ChunksFetchDurationSum += time.Since(fetchBegin)
r.stats.ChunksFetchedSizeSum += units.Base2Bytes(int(part.End - part.Start))

var (
Expand Down Expand Up @@ -2899,7 +2901,6 @@ func (r *bucketChunkReader) loadChunks(ctx context.Context, res []seriesEntry, a
locked = true

r.stats.chunksFetchCount++
r.stats.ChunksFetchDurationSum += time.Since(fetchBegin)
r.stats.ChunksFetchedSizeSum += units.Base2Bytes(len(*nb))
err = populateChunk(&(res[pIdx.seriesEntry].chks[pIdx.chunk]), rawChunk((*nb)[n:]), aggrs, r.save, calculateChunkChecksum)
if err != nil {
Expand Down

0 comments on commit 9ee1a5d

Please sign in to comment.