Skip to content

Commit

Permalink
logging: log time taken for tablet initialization only once (#14597)
Browse files Browse the repository at this point in the history
Signed-off-by: deepthi <[email protected]>
  • Loading branch information
deepthi authored Nov 27, 2023
1 parent 162f346 commit 2464ab5
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions go/vt/vttablet/tabletserver/state_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ func (state servingState) String() string {

// transitionRetryInterval is for tests.
var transitionRetryInterval = 1 * time.Second
var logInitTime sync.Once

// stateManager manages state transition for all the TabletServer
// subcomponents.
Expand Down Expand Up @@ -611,9 +612,9 @@ func (sm *stateManager) setTimeBomb() chan struct{} {

// setState changes the state and logs the event.
func (sm *stateManager) setState(tabletType topodatapb.TabletType, state servingState) {
defer func() {
defer logInitTime.Do(func() {
log.Infof("Tablet Init took %d ms", time.Since(servenv.GetInitStartTime()).Milliseconds())
}()
})
sm.mu.Lock()
defer sm.mu.Unlock()
if tabletType == topodatapb.TabletType_UNKNOWN {
Expand Down

0 comments on commit 2464ab5

Please sign in to comment.