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

log/alt_experimental_level: concept demonstration #444

Closed
wants to merge 2 commits into from

Commits on Jan 20, 2017

  1. log/alt_experimental_level: concept demonstration

    Demonstrate an alternate approach to the "level" package offered via
    the "github.com/go-kit/kit/log/experimental_level" import path,
    allowing log event level filtering via instances of the level.leveler
    interface, created by functions that specify the filtering threshold.
    
    Features not accommodated here for now:
    - Returning an error from log.Log when squelching an event
    - Returning an error from log.Log for events that lack a level
    - Documentation
    
    Benchmarks demonstrate both run time and allocation reduction for the
    disallowed/squelching cases compared to the "experimental_level"
    alternate:
    
    name                     old time/op    new time/op    delta
    NopBaseline-8               459ns ± 0%     130ns ± 0%  -71.68%
    NopDisallowedLevel-8        509ns ± 0%     136ns ± 0%  -73.28%
    NopAllowedLevel-8           515ns ± 0%     494ns ± 0%   -4.08%
    JSONBaseline-8             2.41µs ± 0%    0.13µs ± 0%  -94.45%
    JSONDisallowedLevel-8       506ns ± 0%     136ns ± 0%  -73.12%
    JSONAllowedLevel-8         2.49µs ± 0%    2.45µs ± 0%   -1.48%
    LogfmtBaseline-8           1.08µs ± 0%    0.13µs ± 0%  -87.92%
    LogfmtDisallowedLevel-8     507ns ± 0%     136ns ± 0%  -73.18%
    LogfmtAllowedLevel-8       1.13µs ± 0%    1.10µs ± 0%   -3.26%
    
    name                     old alloc/op   new alloc/op   delta
    NopBaseline-8                288B ± 0%       64B ± 0%  -77.78%
    NopDisallowedLevel-8         288B ± 0%       64B ± 0%  -77.78%
    NopAllowedLevel-8            288B ± 0%      288B ± 0%   +0.00%
    JSONBaseline-8               968B ± 0%       64B ± 0%  -93.39%
    JSONDisallowedLevel-8        288B ± 0%       64B ± 0%  -77.78%
    JSONAllowedLevel-8           968B ± 0%      968B ± 0%   +0.00%
    LogfmtBaseline-8             288B ± 0%       64B ± 0%  -77.78%
    LogfmtDisallowedLevel-8      288B ± 0%       64B ± 0%  -77.78%
    LogfmtAllowedLevel-8         288B ± 0%      288B ± 0%   +0.00%
    
    name                     old allocs/op  new allocs/op  delta
    NopBaseline-8                9.00 ± 0%      3.00 ± 0%  -66.67%
    NopDisallowedLevel-8         9.00 ± 0%      3.00 ± 0%  -66.67%
    NopAllowedLevel-8            9.00 ± 0%      9.00 ± 0%   +0.00%
    JSONBaseline-8               22.0 ± 0%       3.0 ± 0%  -86.36%
    JSONDisallowedLevel-8        9.00 ± 0%      3.00 ± 0%  -66.67%
    JSONAllowedLevel-8           22.0 ± 0%      22.0 ± 0%   +0.00%
    LogfmtBaseline-8             9.00 ± 0%      3.00 ± 0%  -66.67%
    LogfmtDisallowedLevel-8      9.00 ± 0%      3.00 ± 0%  -66.67%
    LogfmtAllowedLevel-8         9.00 ± 0%      9.00 ± 0%   +0.00%
    Steven E. Harris committed Jan 20, 2017
    Configuration menu
    Copy the full SHA
    b7a6343 View commit details
    Browse the repository at this point in the history

Commits on Jan 31, 2017

  1. Accommodate wrapped Logger instances

    Introduce the "log.Delegate" function to extract a wrapped delegate
    Logger instance from a decorating instance, allowing the level-related
    functions to find the configuration they need within the outermost
    Logger created by one of the leveled factory functions.
    
    Benchmarks demonstrate both run time and allocation reduction for the
    disallowed/squelching cases compared to the "experimental_level"
    alternate:
    
    name                     old time/op    new time/op    delta
    NopBaseline-8               470ns ± 0%     494ns ± 0%   +5.11%
    NopDisallowedLevel-8        513ns ± 0%     123ns ± 0%  -76.02%
    NopAllowedLevel-8           516ns ± 0%     474ns ± 0%   -8.14%
    JSONBaseline-8             2.44µs ± 0%    2.39µs ± 0%   -2.45%
    JSONDisallowedLevel-8       515ns ± 0%     123ns ± 0%  -76.12%
    JSONAllowedLevel-8         2.48µs ± 0%    2.33µs ± 0%   -5.97%
    LogfmtBaseline-8           1.05µs ± 0%    1.03µs ± 0%   -2.19%
    LogfmtDisallowedLevel-8     514ns ± 0%     121ns ± 0%  -76.46%
    LogfmtAllowedLevel-8       1.13µs ± 0%    1.02µs ± 0%   -9.39%
    
    name                     old alloc/op   new alloc/op   delta
    NopBaseline-8                288B ± 0%      288B ± 0%   +0.00%
    NopDisallowedLevel-8         288B ± 0%       64B ± 0%  -77.78%
    NopAllowedLevel-8            288B ± 0%      288B ± 0%   +0.00%
    JSONBaseline-8               968B ± 0%      968B ± 0%   +0.00%
    JSONDisallowedLevel-8        288B ± 0%       64B ± 0%  -77.78%
    JSONAllowedLevel-8           968B ± 0%      968B ± 0%   +0.00%
    LogfmtBaseline-8             288B ± 0%      288B ± 0%   +0.00%
    LogfmtDisallowedLevel-8      288B ± 0%       64B ± 0%  -77.78%
    LogfmtAllowedLevel-8         288B ± 0%      288B ± 0%   +0.00%
    
    name                     old allocs/op  new allocs/op  delta
    NopBaseline-8                9.00 ± 0%      9.00 ± 0%   +0.00%
    NopDisallowedLevel-8         9.00 ± 0%      3.00 ± 0%  -66.67%
    NopAllowedLevel-8            9.00 ± 0%      9.00 ± 0%   +0.00%
    JSONBaseline-8               22.0 ± 0%      22.0 ± 0%   +0.00%
    JSONDisallowedLevel-8        9.00 ± 0%      3.00 ± 0%  -66.67%
    JSONAllowedLevel-8           22.0 ± 0%      22.0 ± 0%   +0.00%
    LogfmtBaseline-8             9.00 ± 0%      9.00 ± 0%   +0.00%
    LogfmtDisallowedLevel-8      9.00 ± 0%      3.00 ± 0%  -66.67%
    LogfmtAllowedLevel-8         9.00 ± 0%      9.00 ± 0%   +0.00%
    
    The running time increase in the "NopBaseline-8" benchmare is due to
    the level.Debug function doing more work, needing to inspect the
    supplied log.Logger to see whether it wraps a level restriction that
    would preclude preceding with creating a log.Context to record the
    level.
    Steven E. Harris committed Jan 31, 2017
    Configuration menu
    Copy the full SHA
    c6bd2a9 View commit details
    Browse the repository at this point in the history