-
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.
Browse files
Browse the repository at this point in the history
* feat(logging): Add startup logging for shard counts (#25378) 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 (cherry picked from commit 3c87f52) closes #25506 (cherry picked from commit 2ffb108)
- Loading branch information
Showing
4 changed files
with
359 additions
and
108 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
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)) | ||
} |
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
Oops, something went wrong.