-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
🌱 Add controller-name as kv pair to logger instead of as name #1806
🌱 Add controller-name as kv pair to logger instead of as name #1806
Conversation
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.
I like the idea but it is a breaking change as existing log queries will stop working. Are we comfortable with that?
/hold
pkg/controller/controller.go
Outdated
@@ -135,7 +135,7 @@ func NewUnmanaged(name string, mgr manager.Manager, options Options) (Controller | |||
CacheSyncTimeout: options.CacheSyncTimeout, | |||
SetFields: mgr.SetFields, | |||
Name: name, | |||
Log: options.Log.WithName("controller").WithName(name), | |||
Log: options.Log.WithValues("controller", name), |
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.
@alvaroaleman
Maybe we can/should set the name and k/v?
I just saw this user story in the kubernetes contextual logging KEP:
When kube-scheduler starts processing a pod, it creates a new logger with logger.WithValue("pod", klogr.KObj(pod)) and passes that around. While iterating over plugins in certain operations, another logger gets created with logger.WithName().WithName() and then is used when invoking that plugin. This adds a prefix to each log message which represents the call path to the specific log message, like for example NominatedPods/Filter/VolumeBinding.
https://github.com/kubernetes/enhancements/tree/master/keps/sig-instrumentation/3077-contextual-logging#story-1
To me it seemed strange to have a msg prefix with the controller. But looking at that user story, I can see why folks might want that.
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.
Yeah, that makes sense and seems a good idea
Signed-off-by: Stefan Büringer buringerst@vmware.com
e186709
to
b4d1c56
Compare
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.
thanks!
/hold cancel
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: alvaroaleman, sbueringer The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Signed-off-by: Stefan Büringer buringerst@vmware.com
Addresses #1794. More context in the initial post of #1794