From 948875643737ad0567c7690689b376daf29e9469 Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Thu, 23 Jun 2022 17:41:28 +0300 Subject: [PATCH] rpc: extend error log message for failed RPC requests Message is always non-empty; Data is allowed to be empty. --- pkg/rpc/server/server.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/rpc/server/server.go b/pkg/rpc/server/server.go index 91eabe359..567707d76 100644 --- a/pkg/rpc/server/server.go +++ b/pkg/rpc/server/server.go @@ -2260,7 +2260,10 @@ func (s *Server) packResponse(r *request.In, result interface{}, respErr *respon // logRequestError is a request error logger. func (s *Server) logRequestError(r *request.Request, jsonErr *response.Error) { logFields := []zap.Field{ - zap.String("cause", jsonErr.Data), + zap.Int64("code", jsonErr.Code), + } + if len(jsonErr.Data) != 0 { + logFields = append(logFields, zap.String("cause", jsonErr.Data)) } if r.In != nil {