-
Notifications
You must be signed in to change notification settings - Fork 9.8k
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
[Logs] Consider accepting a zap.Logger rather than zap.Config in embed & client #12326
Comments
This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 21 days if no further activity occurs. Thank you for your contributions. |
Agree. I don't see reasons why we just not support passing logger to embedded & clientv3. clientv3 requires 'wrapping' with: I think I already did a lot of logging simplifications such that RAFT logs and GRPC loggers are |
I will take a look into implementing this |
As long as we support both, sounds good. If logger is not empty, we can overwrite the existing zap log config? |
Hmm, looked through embed config code Lines 347 to 364 in 450fd9a
etcd/server/embed/config_logging.go Lines 201 to 211 in 450fd9a
|
I wonder whether there are resons to build RaftLogger from etcd/server/etcdserver/raft.go Lines 596 to 606 in 70f7e0d
|
No specific reason. Please feel free to make change. The only reason why we required log config is that we wanted to have consistent "default" logging format. |
@serathius is there anything else left for this issue, as I noticed it has a 3.5 nice to have label and with the release approaching. Thank you! |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 21 days if no further activity occurs. Thank you for your contributions. |
@lilic Yes, while clientv3 and server allows passing a zap.Logger directly, embed still does not, it still only supports being passed a ZapLoggerBuilder which is pretty pointless when a logger could just be given directly. |
Embed currently accepts
ZapLoggerBuilder
, and clientv3 accepts aLogConfig
, which in both cases basically takes a zap.Config. However, in order for clients to be able to filter out noisy messages (e.g. clientv3/retry_interceptor.go, or LB Health Checks spamming with bogus TLS connections), a wrapped zapcore.Core must be used, which requires calling(cfg Config) Build(opts ...Option) (*Logger, error)
, which constructs a full logger out of a config struct. Ops could then very simply pass assign the logger a filtering core. A zapcore.Core override could also be used by Ops to do things such as exporting extra metrics based on logs, etc.It really should not change much on the etcd code base side of things - especially as 3.5 is not out yet, but will allow the amount of log noise configuration that once was available with capnslog. For instance:
x-ref #11147
edit May 2021: client.WithLogger lets us override a
zap.Logger
onto clientv3, that's amazing! The very same method could be implemented on Embed.The text was updated successfully, but these errors were encountered: