Skip to content

Commit cf6b8f3

Browse files
authored
Don't log grpc health check OK. (#44)
* Don't log grpc health check OK. * Remove log.
1 parent ed0f83e commit cf6b8f3

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

server/main.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,21 +147,28 @@ func run() {
147147
MinVersion: tls.VersionTLS12,
148148
})
149149

150+
grpcLogDeciderFunc := func(methodFullName string, err error) bool {
151+
if err == nil && methodFullName == "/grpc.health.v1.Health/Check" {
152+
return false
153+
}
154+
return true
155+
}
156+
150157
opts := []grpc.ServerOption{
151158
// Enable TLS for all incoming connections.
152159
grpc.Creds(creds),
153160
grpc.StreamInterceptor(grpc_middleware.ChainStreamServer(
154161
grpc_ctxtags.StreamServerInterceptor(),
155162
grpc_prometheus.StreamServerInterceptor,
156-
grpc_zap.StreamServerInterceptor(logger),
163+
grpc_zap.StreamServerInterceptor(logger, grpc_zap.WithDecider(grpcLogDeciderFunc)),
157164
grpc_auth.StreamServerInterceptor(auther.Auth),
158165
grpc_internalerror.StreamServerInterceptor(),
159166
grpc_recovery.StreamServerInterceptor(),
160167
)),
161168
grpc.UnaryInterceptor(grpc_middleware.ChainUnaryServer(
162169
grpc_ctxtags.UnaryServerInterceptor(),
163170
grpc_prometheus.UnaryServerInterceptor,
164-
grpc_zap.UnaryServerInterceptor(logger),
171+
grpc_zap.UnaryServerInterceptor(logger, grpc_zap.WithDecider(grpcLogDeciderFunc)),
165172
grpc_auth.UnaryServerInterceptor(auther.Auth),
166173
grpc_internalerror.UnaryServerInterceptor(),
167174
grpc_recovery.UnaryServerInterceptor(),

0 commit comments

Comments
 (0)