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 <neeraj@aspenmesh.io>
  • Loading branch information
Neeraj Poddar committed Apr 1, 2019
1 parent 81a1a4d commit 2c39cd4
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions middleware/grpc_logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ func (s GRPCServerLog) UnaryServerInterceptor(ctx context.Context, req interface
if s.WithRequest {
entry = entry.WithField("request", req)
}
entry.WithField(errorKey, err).Warnln(gRPC)
if err == context.Canceled {
entry.WithField(errorKey, err).Debugln(gRPC)
} else {
entry.WithField(errorKey, err).Warnln(gRPC)
}
} else {
entry.Debugf("%s (success)", gRPC)
}
Expand All @@ -44,7 +48,11 @@ 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).Debugln(gRPC)
} else {
entry.WithField(errorKey, err).Warnln(gRPC)
}
} else {
entry.Debugf("%s (success)", gRPC)
}
Expand Down

0 comments on commit 2c39cd4

Please sign in to comment.