avoid logging RPC errors when it's specific rate limiter errors (#15968)

* avoid logging RPC errors when it's specific rate limiter errors

* simplify if statements
pull/15986/head
Dhia Ayachi 2 years ago committed by GitHub
parent 19a46d6ca4
commit 87ff8c1c95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -418,13 +418,21 @@ func (s *Server) handleConsulConn(conn net.Conn) {
} }
if err := s.rpcServer.ServeRequest(rpcCodec); err != nil { if err := s.rpcServer.ServeRequest(rpcCodec); err != nil {
if err != io.EOF && !strings.Contains(err.Error(), "closed") { //EOF or closed are not considered as errors.
s.rpcLogger().Error("RPC error", if err == io.EOF || strings.Contains(err.Error(), "closed") {
"conn", logConn(conn), return
"error", err,
)
metrics.IncrCounter([]string{"rpc", "request_error"}, 1)
} }
metrics.IncrCounter([]string{"rpc", "request_error"}, 1)
// When a rate-limiting error is returned, it's already logged, so skip logging.
if errors.Is(err, rate.ErrRetryLater) || errors.Is(err, rate.ErrRetryElsewhere) {
return
}
s.rpcLogger().Error("RPC error",
"conn", logConn(conn),
"error", err,
)
return return
} }
metrics.IncrCounter([]string{"rpc", "request"}, 1) metrics.IncrCounter([]string{"rpc", "request"}, 1)

Loading…
Cancel
Save