-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(logging): Add startup logging for shard counts (#25378)
* feat(tsdb): Adds shard opening progress checks to startup This PR adds a check to see how many shards are remaining vs how many shards are opened. This change displays the percent completed too. closes influxdata/feature-requests#476
- Loading branch information
Showing
5 changed files
with
462 additions
and
178 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package run | ||
|
||
import ( | ||
"fmt" | ||
"sync/atomic" | ||
|
||
"go.uber.org/zap" | ||
) | ||
|
||
type StartupProgressLogger struct { | ||
shardsCompleted atomic.Uint64 | ||
shardsTotal atomic.Uint64 | ||
logger *zap.Logger | ||
} | ||
|
||
func NewStartupProgressLogger(logger *zap.Logger) *StartupProgressLogger { | ||
return &StartupProgressLogger{ | ||
logger: logger, | ||
} | ||
} | ||
|
||
func (s *StartupProgressLogger) AddShard() { | ||
s.shardsTotal.Add(1) | ||
} | ||
|
||
func (s *StartupProgressLogger) CompletedShard() { | ||
shardsCompleted := s.shardsCompleted.Add(1) | ||
totalShards := s.shardsTotal.Load() | ||
|
||
percentShards := float64(shardsCompleted) / float64(totalShards) * 100 | ||
s.logger.Info(fmt.Sprintf("Finished loading shard, current progress %.1f%% shards (%d / %d).", percentShards, shardsCompleted, totalShards)) | ||
} |
Oops, something went wrong.