Skip to content

Commit

Permalink
Skip logging context cancelled warning msgs
Browse files Browse the repository at this point in the history
Context cancellations are controlled by clients and logging this message can
cause more more confusion as mentioned here:
cortexproject/cortex#1279

Signed-off-by: Neeraj Poddar <[email protected]>
  • Loading branch information
Neeraj Poddar committed Mar 17, 2019
1 parent 81a1a4d commit 4869f24
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions middleware/grpc_logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ func (s GRPCServerLog) UnaryServerInterceptor(ctx context.Context, req interface
resp, err := handler(ctx, req)
entry := user.LogWith(ctx, s.Log).WithFields(logging.Fields{"method": info.FullMethod, "duration": time.Since(begin)})
if err != nil {
if s.WithRequest {
entry = entry.WithField("request", req)
if err != context.Canceled {
if s.WithRequest {
entry = entry.WithField("request", req)
}
entry.WithField(errorKey, err).Warnln(gRPC)
}
entry.WithField(errorKey, err).Warnln(gRPC)
} else {
entry.Debugf("%s (success)", gRPC)
}
Expand All @@ -44,7 +46,9 @@ func (s GRPCServerLog) StreamServerInterceptor(srv interface{}, ss grpc.ServerSt
err := handler(srv, ss)
entry := user.LogWith(ss.Context(), s.Log).WithFields(logging.Fields{"method": info.FullMethod, "duration": time.Since(begin)})
if err != nil {
entry.WithField(errorKey, err).Warnln(gRPC)
if err != context.Canceled {
entry.WithField(errorKey, err).Warnln(gRPC)
}
} else {
entry.Debugf("%s (success)", gRPC)
}
Expand Down

0 comments on commit 4869f24

Please sign in to comment.