Skip to content

Commit

Permalink
clientv3: clarify retry interceptor logging
Browse files Browse the repository at this point in the history
Log only when it errors + some clarification

Signed-off-by: Gyuho Lee <leegyuho@amazon.com>
  • Loading branch information
gyuho committed Feb 14, 2019
1 parent 4cd0bf8 commit 24fc204
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions clientv3/retry_interceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,15 @@ func (c *Client) unaryClientInterceptor(logger *zap.Logger, optFuncs ...retryOpt
return err
}
lastErr = invoker(ctx, method, req, reply, cc, grpcOpts...)
logger.Info("retry unary intercept", zap.Uint("attempt", attempt), zap.Error(lastErr))
if lastErr == nil {
return nil
}
logger.Warn(
"retrying unary intercept",
zap.String("target", cc.Target()),
zap.Uint("attempt", attempt),
zap.Error(lastErr),
)
if isContextError(lastErr) {
if ctx.Err() != nil {
// its the context deadline or cancellation.
Expand All @@ -64,7 +69,11 @@ func (c *Client) unaryClientInterceptor(logger *zap.Logger, optFuncs ...retryOpt
if callOpts.retryAuth && rpctypes.Error(lastErr) == rpctypes.ErrInvalidAuthToken {
gterr := c.getToken(ctx)
if gterr != nil {
logger.Info("retry failed to fetch new auth token", zap.Error(gterr))
logger.Warn(
"retry failed to fetch new auth token",
zap.String("target", cc.Target()),
zap.Error(gterr),
)
return lastErr // return the original error for simplicity
}
continue
Expand Down

0 comments on commit 24fc204

Please sign in to comment.