-
Notifications
You must be signed in to change notification settings - Fork 214
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
Contextual structured logging #239
Comments
/wg structured-logging |
Thanks for creating issue, contextual logging is a great idea! I have added it to WG Roadmap As for api design, I think wait for Kubernetes to migrate to https://github.com/go-logr/logr as it already supports contextual logging. Example:
|
/cc |
The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs. This bot triages issues and PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs. This bot triages issues and PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle rotten |
/remove-lifecycle rotten |
I'm working on a KEP for this. The logr API already supports this, we "just" need to figure out how to use that in Kubernetes. /assign |
Here's the KEP: kubernetes/enhancements#3078 |
/assign The KEP was approved. I'll work on this. |
It's worth pointing out that the solution will not be exactly as in the description. Have a look at the KEP for the proposed API. In contrast to what is currently described in the KEP, we'll probably just add |
Support for contextual logging as I described it in the KEP (logger is part of the context, not "logger uses context") has been implemented in klog and Kubernetes 1.24. I consider that the solution for this issue. /close |
@pohly: Closing this issue. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/kind feature
Describe the solution you'd like
It would be nice to be able to use a context for structured logging. Something like described in this article. Here is a short example from the article:
Something similar could be implemented in order to populate structured logs, example inspired from kubenetes introduction to structured logs:
Output:
Anything else you would like to add:
The form
klog.WithContext(ctx).InfoS("")
would help to avoid breaking changes overklog.InfoS(ctx, "")
. Moreover, introducing new functions likeklog.ContextualInfoS
risks to bloat the api. These are the reasons which make me think that introducing a single new functionklog.WithContext
would be rather a good solution.This article provides some good reasons to use context in logging.
The text was updated successfully, but these errors were encountered: