diff --git a/pkg/store/bucket.go b/pkg/store/bucket.go index 59d943b58f..5a6f31c42d 100644 --- a/pkg/store/bucket.go +++ b/pkg/store/bucket.go @@ -3655,7 +3655,7 @@ func (s queryStats) merge(o *queryStats) *queryStats { s.ChunksFetchedSizeSum += o.ChunksFetchedSizeSum s.chunksFetchCount += o.chunksFetchCount s.ChunksFetchDurationSum += o.ChunksFetchDurationSum - s.ChunksDownloadLatencySum += s.ChunksDownloadLatencySum + s.ChunksDownloadLatencySum += o.ChunksDownloadLatencySum s.GetAllDuration += o.GetAllDuration s.mergedSeriesCount += o.mergedSeriesCount diff --git a/pkg/store/bucket_test.go b/pkg/store/bucket_test.go index 682913b246..3df9359bf4 100644 --- a/pkg/store/bucket_test.go +++ b/pkg/store/bucket_test.go @@ -3485,3 +3485,123 @@ func TestBucketStoreDedupOnBlockSeriesSet(t *testing.T) { })) testutil.Equals(t, 2, len(srv.SeriesSet)) } + +func TestQueryStatsMerge(t *testing.T) { + s := &queryStats{ + blocksQueried: 1, + postingsTouched: 1, + PostingsTouchedSizeSum: 1, + postingsToFetch: 1, + postingsFetched: 1, + PostingsFetchedSizeSum: 1, + postingsFetchCount: 1, + PostingsFetchDurationSum: 1, + cachedPostingsCompressions: 1, + cachedPostingsCompressionErrors: 1, + CachedPostingsOriginalSizeSum: 1, + CachedPostingsCompressedSizeSum: 1, + CachedPostingsCompressionTimeSum: 1, + cachedPostingsDecompressions: 1, + cachedPostingsDecompressionErrors: 1, + CachedPostingsDecompressionTimeSum: 1, + seriesTouched: 1, + SeriesTouchedSizeSum: 1, + seriesFetched: 1, + SeriesFetchedSizeSum: 1, + seriesFetchCount: 1, + SeriesFetchDurationSum: 1, + SeriesDownloadLatencySum: 1, + chunksTouched: 1, + ChunksTouchedSizeSum: 1, + chunksFetched: 1, + ChunksFetchedSizeSum: 1, + chunksFetchCount: 1, + ChunksFetchDurationSum: 1, + ChunksDownloadLatencySum: 1, + GetAllDuration: 1, + mergedSeriesCount: 1, + mergedChunksCount: 1, + MergeDuration: 1, + DataDownloadedSizeSum: 1, + } + + o := &queryStats{ + blocksQueried: 100, + postingsTouched: 100, + PostingsTouchedSizeSum: 100, + postingsToFetch: 100, + postingsFetched: 100, + PostingsFetchedSizeSum: 100, + postingsFetchCount: 100, + PostingsFetchDurationSum: 100, + cachedPostingsCompressions: 100, + cachedPostingsCompressionErrors: 100, + CachedPostingsOriginalSizeSum: 100, + CachedPostingsCompressedSizeSum: 100, + CachedPostingsCompressionTimeSum: 100, + cachedPostingsDecompressions: 100, + cachedPostingsDecompressionErrors: 100, + CachedPostingsDecompressionTimeSum: 100, + seriesTouched: 100, + SeriesTouchedSizeSum: 100, + seriesFetched: 100, + SeriesFetchedSizeSum: 100, + seriesFetchCount: 100, + SeriesFetchDurationSum: 100, + SeriesDownloadLatencySum: 100, + chunksTouched: 100, + ChunksTouchedSizeSum: 100, + chunksFetched: 100, + ChunksFetchedSizeSum: 100, + chunksFetchCount: 100, + ChunksFetchDurationSum: 100, + ChunksDownloadLatencySum: 100, + GetAllDuration: 100, + mergedSeriesCount: 100, + mergedChunksCount: 100, + MergeDuration: 100, + DataDownloadedSizeSum: 100, + } + + // Expected stats. + e := &queryStats{ + blocksQueried: 101, + postingsTouched: 101, + PostingsTouchedSizeSum: 101, + postingsToFetch: 101, + postingsFetched: 101, + PostingsFetchedSizeSum: 101, + postingsFetchCount: 101, + PostingsFetchDurationSum: 101, + cachedPostingsCompressions: 101, + cachedPostingsCompressionErrors: 101, + CachedPostingsOriginalSizeSum: 101, + CachedPostingsCompressedSizeSum: 101, + CachedPostingsCompressionTimeSum: 101, + cachedPostingsDecompressions: 101, + cachedPostingsDecompressionErrors: 101, + CachedPostingsDecompressionTimeSum: 101, + seriesTouched: 101, + SeriesTouchedSizeSum: 101, + seriesFetched: 101, + SeriesFetchedSizeSum: 101, + seriesFetchCount: 101, + SeriesFetchDurationSum: 101, + SeriesDownloadLatencySum: 101, + chunksTouched: 101, + ChunksTouchedSizeSum: 101, + chunksFetched: 101, + ChunksFetchedSizeSum: 101, + chunksFetchCount: 101, + ChunksFetchDurationSum: 101, + ChunksDownloadLatencySum: 101, + GetAllDuration: 101, + mergedSeriesCount: 101, + mergedChunksCount: 101, + MergeDuration: 101, + DataDownloadedSizeSum: 101, + } + + output := s.merge(o) + testutil.Equals(t, e, output) +}