-
Notifications
You must be signed in to change notification settings - Fork 75
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
fix: allow grpc logger to truncate specific methods output #1360
Conversation
@@ -240,40 +240,48 @@ func verifyUnaryInterceptor() grpc.UnaryServerInterceptor { | |||
// | |||
// Note, that to enable tracing logging you should specify this option AFTER | |||
// trace interceptors. | |||
func RequestLogInterceptor(log *zap.Logger) ServerOption { | |||
func RequestLogInterceptor(log *zap.Logger, truncatedMethods []string) ServerOption { | |||
var truncatedMethodsSet = map[string]bool{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is more common to use map[string]struct{}
for sets (yep, go sucks)
return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) { | ||
executeRequestLogging(ctx, req, info.FullMethod, log) | ||
executeRequestLogging(ctx, req, info.FullMethod, log, truncatedMethods[MethodInfo(info.FullMethod).Method]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did you test it? Because go panics on missing key
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nuh-uh no it doesn't
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, it looks like I was not drunk
Short method names should be provided, i.e.,
PushTask
, not/sonm.Worker/PushTask
.