2
votes

We have a custom ServerInterceptor for logging every call our grpc-java server receives. It wraps the ServerCall passed on to next::startCall with a SimpleForwardingServerCall that overrides close(Status,Metadata) for logging the status of the call and tracking total time elapsed between interceptCall and close. We expected this to result in logging status and tracking elapsed time for every call received.

We've found one case where our interceptor logged in the body of interceptCall, and then an inner interceptor did some logging in its interceptCall, but we never saw any more logging for the request. Other context suggests that there were connection issues between the client and server at the time.

Can we expect ServerCall::close(Status,Metadata) be called for every RPC call, regardless of client or connection misbehavior? If not, is there some other callback that we may have missed that would indicate that a call has "died?"

1

1 Answers

2
votes

You want ServerCall.Listener.onComplete() and ServerCall.Listener.onCancel(). onComplete() is called after ServerCall.close() is processed successfully. onCancel() is used for any communication error or cancellation. Note that it is possible to receive onCancel() after the application calls ServerCall.close().