Reputation: 396
I have a gRPC server written in C++ and I would like to trace or log all RPC calls to the server, including arguments and responses, if possible.
The Go gRPC implementation has the very helpful concept of an Interceptor that can be attached to a client or a server. The interceptor gets access to not only the metadata, but also to the arguments/responses. For the C++ API I cannot find anything similar.
Upvotes: 2
Views: 4385
Reputation: 430
What about https://grpc.github.io/grpc/cpp/classgrpc_1_1experimental_1_1_interceptor.html ?
The only usage reference I could find is this SO question: C++ grpc::experimental:interceptor how to return status and message from custom interceptor
EDIT: in matter of fact, I think this is a better resource - https://github.com/grpc/grpc/blob/7bf82de9eda0aa8fecfe5edb33834f1b272be30b/test/cpp/end2end/server_interceptors_end2end_test.cc
I think you can query the request & response messages from the methods
argument of the interceptor overridden method Intercept(grpc::experimental::InterceptorBatchMethods* methods)
, see available methods and properties here: https://grpc.github.io/grpc/cpp/classgrpc_1_1experimental_1_1_interceptor_batch_methods.html
Upvotes: 2