go-grpc-middleware
go-grpc-middleware copied to clipboard
Improve docs around grpc_zap.WithDecider
When creating a client interceptor, despite selecting an opt with WithDecider set to a function that always returns false, I have noticed I am still getting DEBUG entries to zap, for example unary client calls would get a "finished client unary call" for every call
should there be something like
err := invoker(ctx, method, req, reply, cc, opts...)
+ if !o.shouldLog(method, err) {
+ return err
+ }
logFinalClientLine(o, logger.With(fields...), startTime, err, "finished client unary call")
in client_interceptors.go's Unary/StreamClientInterceptor functions to prevent the call to logFinalClientLine similar to how this looks like being handled on the server-side of things?
The WithDecider
is only useful for Payload*
interception and logging. We should improve docs here.
Wouldn't it be still useful to be able to call a decider on normal logging regardless? On the server side as I was saying there are no "finished call" logging messages on filtered events because UnaryServerInterceptor calls shouldLog before the "finished call" message. This was added later via #113 in server_interceptors.go.
Given the two functions UnaryServerInterceptor and UnaryClientInterceptor are fairly similar I figured the enhancement that was merged on the server side could be applicable on the client side as well. Of course I might be misunderstanding the intent, so will be looking for the doc changes to clarify, thanks!
@domgreen can you please weigh in, as you authored the #113 change?
hi, i'm working on a grpc proxy stuff, using both server and client side interceptor. and i find that client side decider is useful, since i only want to log suspicious non-ok request.
i also think it's good idea to keep an consistent semantics as possible. isn't it?
This is pretty old and we know have v2
code with different structure. Let us know if this is still important, we can reopen.