fs: fix goroutine leak and improve stats accounting process

This fixes the go routine leak in the stats accounting

- don't start stats average loop when initializing `StatsInfo`
- stop the loop instead of pausing
- use a context instead of a channel
- move `period` variable in `averageValues` struct

Fixes #8570
This commit is contained in:
Nathanael Demacon
2025-06-04 14:43:19 +01:00
committed by GitHub
parent 5173ca0454
commit ddebca8d42
2 changed files with 20 additions and 49 deletions

View File

@ -298,6 +298,7 @@ func GlobalStats() *StatsInfo {
// NewStatsGroup creates new stats under named group.
func NewStatsGroup(ctx context.Context, group string) *StatsInfo {
stats := NewStats(ctx)
stats.startAverageLoop()
stats.group = group
groups.set(ctx, group, stats)
return stats