mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-12-05 02:11:10 +01:00
rpc: add unary+streaming interceptors to log all errors
Not all errors that occur when serving client requests in the gRPC server are logged. As a result, at times, we can be lacking critic information that can be used to debug issues that pop up. With this PR, we create a basic streaming+unary interceptor that will log all errors that occur when servicing calls. The current format looks something like this in the logs when an error occurs: ``` [ERR] RPCS: [/lnrpc.Lightning/SendCoins]: decoded address is of unknown format ```
This commit is contained in:
@@ -560,6 +560,15 @@ func newRPCServer(s *server, macService *macaroons.Service,
|
||||
unaryInterceptors := append(macUnaryInterceptors, promUnaryInterceptors...)
|
||||
strmInterceptors := append(macStrmInterceptors, promStrmInterceptors...)
|
||||
|
||||
// We'll also add our logging interceptors as well, so we can
|
||||
// automatically log all errors that happen during RPC calls.
|
||||
unaryInterceptors = append(
|
||||
unaryInterceptors, errorLogUnaryServerInterceptor(rpcsLog),
|
||||
)
|
||||
strmInterceptors = append(
|
||||
strmInterceptors, errorLogStreamServerInterceptor(rpcsLog),
|
||||
)
|
||||
|
||||
// If any interceptors have been set up, add them to the server options.
|
||||
if len(unaryInterceptors) != 0 && len(strmInterceptors) != 0 {
|
||||
chainedUnary := grpc_middleware.WithUnaryServerChain(
|
||||
|
||||
Reference in New Issue
Block a user