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

Use structured logging #289

Closed
aybabtme opened this issue Aug 13, 2015 · 9 comments
Closed

Use structured logging #289

aybabtme opened this issue Aug 13, 2015 · 9 comments
Labels
P3 Type: Feature New features or improvements in behavior

Comments

@aybabtme
Copy link

This package emits a lot of logs when it encounters errors. It would be nice if the logging could be done in a structured manner, so that machine be able to parse them and make sense of the various piece of information found in them.

For instance, at DigitalOcean we log everything in JSON and send all the logs to a centralized store, where we can perform query and analyse our logs in bulk. We structure our logs in a manner such that this log entry:

log.WithFields(log.Fields{
   "err":       err,
   "peer.addr": peerAddr,
   "timeout_s": timeout.Seconds(),
}).Error("timeout connecting to remote peer")

Prints something like:

{"time":"2015-08-12T23:31:10-04:00","level":"fatal","err":"grpc: timed out trying to connect","peer.addr":"10.0.0.1:6767", "timeout_s":29.1,"msg":"timeout connecting to remote peer"}

We can then run queries about the most frequent errors involving peer.addr = "some address".

So essentially I'm proposing modifying grpc-go/grpclog to match another interface, and then modifying all log sites to leverage structured logging patterns. There's a standard structured logger coming up in the community:

If you're interested, I could work on a patch.

@aybabtme
Copy link
Author

I have this insane grpclog implementation for now :P https://github.com/aybabtme/grpclogrus

@iamqizhao
Copy link
Contributor

The idea sounds fine to me. Thanks for contribution.

@aybabtme
Copy link
Author

aybabtme commented Sep 4, 2015

@peter-edge I guess that could be 1 implementation among many, my idea here is to use a structured logging interface instead of printf-logging. The backing implementation isn't really something important to me =P.

@aybabtme
Copy link
Author

aybabtme commented Feb 4, 2016

I prepared this deck about why structured logging matters, could help motivate why we'd like to see GRPC use it somehow:

https://docs.google.com/presentation/d/1SnjZpcfJq9r6OpgsjsX9ExCFTQgpXsSjD--Y3PPDiAQ/edit?usp=sharing

It's a bit annoying that a library be logging on it's own, with its own means. At least logging to key-values would leave the choice to users to printf the stuff together as needed (and a default grpclog), or keep the key-value mappings and do nice parseable logs.

@hsaliak
Copy link

hsaliak commented May 17, 2017

I do not believe we have plans to do structured logging at the moment. @menghanl @dfawley could you take a look and see what to do with this proposed enhancement.

@aybabtme
Copy link
Author

hi @hsaliak, @menghanl and @dfawley ! I haven't contributed to the discussion for a while, but I think the need is still very present. If we can agree on an interface, I'm happy to do the work myself.

@hsaliak
Copy link

hsaliak commented May 18, 2017

Sounds good, this may make a good gRFC proposal. I'll defer to @dfawley though

@dfawley dfawley added Type: Feature New features or improvements in behavior and removed Type: Enhancement labels Aug 24, 2017
@dfawley dfawley added the P3 label Oct 19, 2017
@dfawley
Copy link
Member

dfawley commented Jun 13, 2018

We're open to this idea, but we would like to see a design proposal first (either as a grfc or a write-up in this bug), and would need a contribution to implement it as well.

@dfawley
Copy link
Member

dfawley commented May 3, 2021

Closing due to lack of activity and priority.

@dfawley dfawley closed this as completed May 3, 2021
dfawley pushed a commit to dfawley/grpc-go that referenced this issue Sep 24, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 31, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
P3 Type: Feature New features or improvements in behavior
Projects
None yet
Development

No branches or pull requests

5 participants