-
Notifications
You must be signed in to change notification settings - Fork 38.7k
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
scheduler: contextual logging - WithName and WithValue #111155
Closed
knelasevero
wants to merge
8
commits into
kubernetes:master
from
knelasevero:log-contextual-scheduler-withnames-withvalues
Closed
scheduler: contextual logging - WithName and WithValue #111155
knelasevero
wants to merge
8
commits into
kubernetes:master
from
knelasevero:log-contextual-scheduler-withnames-withvalues
Commits on Feb 16, 2023
-
scheduler: support contextual logging
This replaces all log calls through the global klog logger with a logger that gets passed in by the caller, either through an explicit parameter or the context. This makes it possible to produce more informative log output by adding WithName and/or WithValues instrumentation (not done yet!). It also makes "go test" failures more useful because the log output gets associated with the test which produced it. Usually, context is the more future-proof option. It has happened repeatedly throughout the life of this commit that a function that originally had no context later got changed in the master branch to accept for reasons unrelated to contextual logging. In several places, passing a context can replace passing a stop channel and then serves two purposes (access to logger and cancellation). But klog.FromContext has some overhead, so for simple functions a logger is passed.
Configuration menu - View commit details
-
Copy full SHA for 3d64f4f - Browse repository at this point
Copy the full SHA 3d64f4fView commit details -
This enables benchmarking with JSON selected as output.
Configuration menu - View commit details
-
Copy full SHA for f3fb344 - Browse repository at this point
Copy the full SHA f3fb344View commit details -
scheduler: use WithName and WithValues
This adds a prefix to each log entry that shows which operation and/or component produced the log entry (WithName) and ensures that relevant additional values, in particular the pod that gets scheduled, are always included (WithValues). This makes log entries easier to understand, in particular when multiple pods get scheduled in parallel. The downside is the constant overhead for these additional calls: they need to do some work, whether log entries will be printed or not.
Configuration menu - View commit details
-
Copy full SHA for da3ebdb - Browse repository at this point
Copy the full SHA da3ebdbView commit details -
Configuration menu - View commit details
-
Copy full SHA for 66014b2 - Browse repository at this point
Copy the full SHA 66014b2View commit details -
Configuration menu - View commit details
-
Copy full SHA for c553787 - Browse repository at this point
Copy the full SHA c553787View commit details -
Configuration menu - View commit details
-
Copy full SHA for f68989a - Browse repository at this point
Copy the full SHA f68989aView commit details -
Configuration menu - View commit details
-
Copy full SHA for 5820e79 - Browse repository at this point
Copy the full SHA 5820e79View commit details -
Configuration menu - View commit details
-
Copy full SHA for 591592b - Browse repository at this point
Copy the full SHA 591592bView commit details
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.