Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WithDecider gone but referenced on documentation #710

Open
JosemyDuarte opened this issue May 7, 2024 · 1 comment
Open

WithDecider gone but referenced on documentation #710

JosemyDuarte opened this issue May 7, 2024 · 1 comment

Comments

@JosemyDuarte
Copy link

Hi!

I'm migrating from 1.4.0 to 2.1.0 and we were using WithDecider. I see it still referenced on the documentation

All logging middleware will emit a final log statement. It is based on the error returned by the handler function,
the gRPC status code, an error (if any) and it emits at a level controlled via `WithLevels`. You can control this behavior
using `WithDecider`.

But is not implemented anywhere, what is the advisable way to accomplish similar results with v2 API? I would be happy to update the docs with this information as well.

@JosemyDuarte
Copy link
Author

JosemyDuarte commented May 7, 2024

Somehow I missed this from the README

All "deciders", so functions that decide what to do based on gRPC service name and method (aka "fullMethodName") are removed (!). Use github.com/grpc-ecosystem/go-grpc-middleware/v2/interceptors/selector interceptor to select what method, type or service should use what interceptor.

I guess the doc should be updated with it, but I'm still about to investigate how to use the Selector as a replacement of WithDecider since I don't see err on CallMeta.

This is what I'm trying to translate to Selector approach:

loggingOpts := []grpczap.Option{
		grpczap.WithDecider(func(fullMethodName string, err error) bool {
			// Only log errors
			return err != nil
		}),
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant