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

WIP: scheduler: contextual logging #110833

Closed
wants to merge 5 commits into from

Commits on Jun 28, 2022

  1. 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.
    pohly committed Jun 28, 2022
    Configuration menu
    Copy the full SHA
    e0b9d79 View commit details
    Browse the repository at this point in the history
  2. scheduler_perf: support JSON

    This enables benchmarking with JSON selected as output.
    pohly committed Jun 28, 2022
    Configuration menu
    Copy the full SHA
    408a28e View commit details
    Browse the repository at this point in the history
  3. 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.
    pohly committed Jun 28, 2022
    Configuration menu
    Copy the full SHA
    01b8046 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    32596ed View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    f7ac1e3 View commit details
    Browse the repository at this point in the history