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

log,grpc: simpler gRPC logger for server #348

Merged
merged 2 commits into from
Oct 16, 2023
Merged

Conversation

jchappelow
Copy link
Member

Spinning this out of some ongoing work with the gRPC service because the server's RPC logging is excessively verbose.

This replaces the interceptor logger with a new SimpleInterceptorLogger that logs with more sensible information, severity levels, and only on RPC completion rather than both start/stop of request.

Before

{"level":"info","ts":1697148715.6290593,"logger":"kwild.grpc-server","msg":"started call","protocol":"grpc","grpc.component":"server","grpc.service":"tx.TxService","grpc.method":"GetSchema","grpc.method_type":"unary","peer.address":"127.0.0.1:34840","grpc.start_time":"2023-10-12T17:11:55-05:00","grpc.time_ms":"0.02"}
{"level":"info","ts":1697148715.6291308,"logger":"kwild.grpc-server","msg":"finished call","protocol":"grpc","grpc.component":"server","grpc.service":"tx.TxService","grpc.method":"GetSchema","grpc.method_type":"unary","peer.address":"127.0.0.1:34840","grpc.start_time":"2023-10-12T17:11:55-05:00","grpc.code":"OK","grpc.time_ms":"0.097"}

After

{"level":"info","ts":1697152104.4972465,"logger":"kwild.grpc-server","msg":"call success","method":"tx.TxService/ListDatabases","elapsed":"0.052ms","code":"OK"}

func codeToLevel(code codes.Code) log.Level {
switch code {
case codes.OK:
return log.InfoLevel // log.DebugLevel
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be Debug level at some point. Virtually every node will not log every successful RPC, although we are early and this is still helpful.

@jchappelow jchappelow changed the title pkg/log,grpc: simpler gRPC logger for server log,grpc: simpler gRPC logger for server Oct 13, 2023
@brennanjl brennanjl merged commit c7a4155 into main Oct 16, 2023
2 checks passed
@brennanjl brennanjl deleted the simpler-grpc-logger branch October 16, 2023 01:52
@jchappelow jchappelow added this to the v0.6.0 milestone Nov 6, 2023
brennanjl pushed a commit that referenced this pull request Feb 26, 2024
* pkg/log,grpc: simpler gRPC logger for server

* include client address
brennanjl pushed a commit that referenced this pull request Feb 26, 2024
* pkg/log,grpc: simpler gRPC logger for server

* include client address
jchappelow added a commit that referenced this pull request Feb 26, 2024
* pkg/log,grpc: simpler gRPC logger for server

* include client address
brennanjl pushed a commit that referenced this pull request Feb 26, 2024
* pkg/log,grpc: simpler gRPC logger for server

* include client address
brennanjl pushed a commit that referenced this pull request Feb 26, 2024
* pkg/log,grpc: simpler gRPC logger for server

* include client address
brennanjl pushed a commit that referenced this pull request Feb 26, 2024
* pkg/log,grpc: simpler gRPC logger for server

* include client address
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

Successfully merging this pull request may close these issues.

2 participants