go-grpc-middleware icon indicating copy to clipboard operation
go-grpc-middleware copied to clipboard

Improve docs around grpc_zap.WithDecider

Open woodensquares opened this issue 6 years ago • 4 comments

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?

woodensquares avatar Mar 12 '18 21:03 woodensquares

The WithDecider is only useful for Payload* interception and logging. We should improve docs here.

mwitkow avatar Mar 31 '18 11:03 mwitkow

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!

woodensquares avatar Apr 01 '18 18:04 woodensquares

@domgreen can you please weigh in, as you authored the #113 change?

mwitkow avatar Apr 02 '18 17:04 mwitkow

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?

cfz avatar Apr 07 '21 06:04 cfz

This is pretty old and we know have v2 code with different structure. Let us know if this is still important, we can reopen.

bwplotka avatar Mar 19 '23 01:03 bwplotka