Skip to content

Commit

Permalink
chore: Add new field to "stats-report" log line in bloom gateway (#14446
Browse files Browse the repository at this point in the history
)

This new field reports how many blocks have been processed in total in the multiplexed request.

Signed-off-by: Christian Haudum <[email protected]>
  • Loading branch information
chaudum authored and trevorwhitney committed Oct 10, 2024
1 parent 4a4fe50 commit 3d500b8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
1 change: 1 addition & 0 deletions pkg/bloomgateway/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ func (p *processor) processTasksForDay(ctx context.Context, _ string, _ config.D

for _, t := range tasks {
FromContext(t.ctx).AddBlocksFetchTime(duration)
FromContext(t.ctx).AddProcessedBlocksTotal(len(tasksByBlock))
}

if err != nil {
Expand Down
28 changes: 19 additions & 9 deletions pkg/bloomgateway/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ type Stats struct {
MetasFetchTime, BlocksFetchTime *atomic.Duration
ProcessingTime, TotalProcessingTime *atomic.Duration
PostProcessingTime *atomic.Duration
ProcessedBlocks *atomic.Int32
ProcessedBlocks *atomic.Int32 // blocks processed for this specific request
ProcessedBlocksTotal *atomic.Int32 // blocks processed for multiplexed request
}

type statsKey int
Expand All @@ -26,14 +27,15 @@ var ctxKey = statsKey(0)
// ContextWithEmptyStats returns a context with empty stats.
func ContextWithEmptyStats(ctx context.Context) (*Stats, context.Context) {
stats := &Stats{
Status: "unknown",
ProcessedBlocks: atomic.NewInt32(0),
QueueTime: atomic.NewDuration(0),
MetasFetchTime: atomic.NewDuration(0),
BlocksFetchTime: atomic.NewDuration(0),
ProcessingTime: atomic.NewDuration(0),
TotalProcessingTime: atomic.NewDuration(0),
PostProcessingTime: atomic.NewDuration(0),
Status: "unknown",
ProcessedBlocks: atomic.NewInt32(0),
ProcessedBlocksTotal: atomic.NewInt32(0),
QueueTime: atomic.NewDuration(0),
MetasFetchTime: atomic.NewDuration(0),
BlocksFetchTime: atomic.NewDuration(0),
ProcessingTime: atomic.NewDuration(0),
TotalProcessingTime: atomic.NewDuration(0),
PostProcessingTime: atomic.NewDuration(0),
}
ctx = context.WithValue(ctx, ctxKey, stats)
return stats, ctx
Expand Down Expand Up @@ -72,6 +74,7 @@ func (s *Stats) KVArgs() []any {
"tasks", s.NumTasks,
"matchers", s.NumMatchers,
"blocks_processed", s.ProcessedBlocks.Load(),
"blocks_processed_total", s.ProcessedBlocksTotal.Load(),
"series_requested", s.SeriesRequested,
"series_filtered", s.SeriesFiltered,
"chunks_requested", s.ChunksRequested,
Expand Down Expand Up @@ -135,3 +138,10 @@ func (s *Stats) IncProcessedBlocks() {
}
s.ProcessedBlocks.Inc()
}

func (s *Stats) AddProcessedBlocksTotal(delta int) {
if s == nil {
return
}
s.ProcessedBlocksTotal.Add(int32(delta))
}

0 comments on commit 3d500b8

Please sign in to comment.