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

contextual logging #108995

Merged
merged 5 commits into from
Mar 30, 2022
Merged

contextual logging #108995

merged 5 commits into from
Mar 30, 2022

Commits on Mar 29, 2022

  1. json: test WithName

    At the moment, the zap configuration ignores the WithName values.
    pohly committed Mar 29, 2022
    Configuration menu
    Copy the full SHA
    3fe5b3e View commit details
    Browse the repository at this point in the history
  2. json: enable WithName logging

    The name added to a logger via WithName only gets printed when a key is
    chosen. "logger" is used as in the zap examples.
    
    This becomes relevant once we support contextual logging. When logging through
    klog the name is always empty.
    pohly committed Mar 29, 2022
    Configuration menu
    Copy the full SHA
    ab318cf View commit details
    Browse the repository at this point in the history
  3. json: test handling of duplicate keys

    We want to see in the output when keys are used more than once. This should be
    fixed because parsing the log messages as JSON will only preserve one of the
    values.
    pohly committed Mar 29, 2022
    Configuration menu
    Copy the full SHA
    ef30d84 View commit details
    Browse the repository at this point in the history
  4. logs: pass verbosity to loggers

    When a Logger gets called directly via contextual logging, it has to do its own
    verbosity check and therefore needs to know what the intended verbosity level
    is.
    
    This used to work previously because all verbosity checks were done in klog
    before invoking the Logger.
    pohly committed Mar 29, 2022
    Configuration menu
    Copy the full SHA
    b390d01 View commit details
    Browse the repository at this point in the history
  5. logging: add ContextualLogging feature

    InitLogs overrides the klog default and turns contextual logging off. This
    ensures that it is only enabled in Kubernetes commands that explicitly enable
    it via a feature gate. A feature gate for it gets defined in
    k8s.io/component-base/logs and is then used by Options.ValidateAndApply.
    
    The effect of disabling contextual logging is very limited according to
    benchmarks with kube-scheduler. The feature gets added anyway to satisfy the
    PRR recommendation that features should be controllable.
    
    The following commands have support for contextual logging:
    - kube-apiserver
    - kube-controller-manager
    - kubelet
    - kube-scheduler
    - component-base/logs example
    
    Supporting a feature gate check in ValidateAndApply and not in InitLogs is a
    simplification: changing InitLogs to accept a FeatureGate would have implied
    changing also component-base/cli.Run. This didn't seem worthwhile because
    ValidateAndApply already covers the relevant commands.
    pohly committed Mar 29, 2022
    Configuration menu
    Copy the full SHA
    7de1b05 View commit details
    Browse the repository at this point in the history