Store: Make queryStats log with human-readable format. #4885
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The queryStats log is very useful to debug query in thanos-store.
But currently the duration field is unexported so that
fmt.Printf("%+v", stats)
print a number for time.Duration.Before:
level=debug msg="stats query processed" stats="&{blocksQueried:1 postingsTouched:102 postingsTouchedSizeSum:1122 postingsToFetch:0 postingsFetched:1 postingsFetchedSizeSum:404 postingsFetchCount:1 postingsFetchDurationSum:162905 cachedPostingsCompressions:1 cachedPostingsCompressionErrors:0 cachedPostingsOriginalSizeSum:404 cachedPostingsCompressedSizeSum:18 cachedPostingsCompressionTimeSum:29569 cachedPostingsDecompressions:101 cachedPostingsDecompressionErrors:0 cachedPostingsDecompressionTimeSum:65901 seriesTouched:100 seriesTouchedSizeSum:1229 seriesFetched:54 seriesFetchedSizeSum:67120 seriesFetchCount:1 seriesFetchDurationSum:247635 chunksTouched:100 chunksTouchedSizeSum:1236 chunksFetched:100 chunksFetchedSizeSum:17817 chunksFetchCount:1 chunksFetchDurationSum:135030 getAllDuration:1744138 mergedSeriesCount:100 mergedChunksCount:100 mergeDuration:106200}" err=null
After:
level=debug msg="stats query processed" request="max_time:99 matchers: matchers: matchers: " stats="&{blocksQueried:2 postingsTouched:203 postingsTouchedSizeSum:2812 postingsToFetch:0 postingsFetched:203 postingsFetchedSizeSum:4478 postingsFetchCount:2 PostingsFetchDurationSum:576.127µs cachedPostingsCompressions:203 cachedPostingsCompressionErrors:0 cachedPostingsOriginalSizeSum:2812 cachedPostingsCompressedSizeSum:1454 CachedPostingsCompressionTimeSum:358.132µs cachedPostingsDecompressions:0 cachedPostingsDecompressionErrors:0 CachedPostingsDecompressionTimeSum:0s seriesTouched:100 seriesTouchedSizeSum:1229 seriesFetched:100 seriesFetchedSizeSum:68592 seriesFetchCount:1 SeriesFetchDurationSum:353.677µs chunksTouched:100 chunksTouchedSizeSum:1236 chunksFetched:100 chunksFetchedSizeSum:17817 chunksFetchCount:1 ChunksFetchDurationSum:221.653µs GetAllDuration:4.764037ms mergedSeriesCount:100 mergedChunksCount:100 MergeDuration:127.72µs}" err=null
Signed-off-by: Jimmie Han hanjinming@outlook.com
Changes
Verification
Unit test