Skip to content

Commit f1fc2ca

Browse files
authored
clientconn: add channel ID to some idleness logs (#6459)
1 parent 9bb44fb commit f1fc2ca

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

clientconn.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ func (cc *ClientConn) exitIdleMode() error {
325325
}
326326
if cc.idlenessState != ccIdlenessStateIdle {
327327
cc.mu.Unlock()
328-
logger.Info("ClientConn asked to exit idle mode when not in idle mode")
328+
channelz.Infof(logger, cc.channelzID, "ClientConn asked to exit idle mode, current mode is %v", cc.idlenessState)
329329
return nil
330330
}
331331

@@ -396,7 +396,7 @@ func (cc *ClientConn) enterIdleMode() error {
396396
return ErrClientConnClosing
397397
}
398398
if cc.idlenessState != ccIdlenessStateActive {
399-
logger.Error("ClientConn asked to enter idle mode when not active")
399+
channelz.Errorf(logger, cc.channelzID, "ClientConn asked to enter idle mode, current mode is %v", cc.idlenessState)
400400
return nil
401401
}
402402

@@ -667,6 +667,19 @@ const (
667667
ccIdlenessStateExitingIdle
668668
)
669669

670+
func (s ccIdlenessState) String() string {
671+
switch s {
672+
case ccIdlenessStateActive:
673+
return "active"
674+
case ccIdlenessStateIdle:
675+
return "idle"
676+
case ccIdlenessStateExitingIdle:
677+
return "exitingIdle"
678+
default:
679+
return "unknown"
680+
}
681+
}
682+
670683
// WaitForStateChange waits until the connectivity.State of ClientConn changes from sourceState or
671684
// ctx expires. A true value is returned in former case and false in latter.
672685
//

0 commit comments

Comments
 (0)