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

sampler: Support thereafter of zero #1033

Merged
merged 1 commit into from Dec 8, 2021
Merged

sampler: Support thereafter of zero #1033

merged 1 commit into from Dec 8, 2021

Conversation

abhinav
Copy link
Contributor

@abhinav abhinav commented Dec 8, 2021

The Zap sampling logger accepts three configuration parameters:
interval, first, and thereafter.

After we see first log with the same message in interval,
the sampler kicks in.
Following that, we let through every thereafter-th log.

So for example,

NewSamplerWithOptions(core, time.Second, 100, 50)

This will allow 100 logs with the same message in a second,
and following that, every 50th message with that message.

In #1032, the user wanted the sampler to reject all duplicate messages
once the limit was reached, but our sampler panics if thereafter = 0.

This change adds support for setting thereafter to 0,
dropping all messages in that interval once the limit is reached.
It also adds further explanation to the documentation to address the
misuse in #1032.

Resolves #1032

The Zap sampling logger accepts three configuration parameters:
interval, first, and thereafter.

After we see `first` log with the same message in `interval`,
the sampler kicks in.
Following that, we let through every `thereafter`-th log.

So for example,

    NewSamplerWithOptions(core, time.Second, 100, 50)

This will allow 100 logs with the same message in a second,
and following that, every 50th message with that message.

In #1032, the user wanted the sampler to reject *all* duplicate messages
once the limit was reached, but our sampler panics
if `thereafter = 0`.

This change adds support for setting `thereafter` to 0,
dropping all messages in that interval once the limit is reached.
It also adds further explanation to the documentation to address the
misuse in #1032.

Resolves #1032
@abhinav abhinav requested a review from sywhang December 8, 2021 20:34
@codecov
Copy link

codecov bot commented Dec 8, 2021

Codecov Report

Merging #1033 (65e213f) into master (10b1fe4) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1033   +/-   ##
=======================================
  Coverage   98.20%   98.20%           
=======================================
  Files          47       47           
  Lines        2067     2067           
=======================================
  Hits         2030     2030           
  Misses         29       29           
  Partials        8        8           
Impacted Files Coverage Δ
zapcore/sampler.go 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 10b1fe4...65e213f. Read the comment docs.

sywhang
sywhang approved these changes Dec 8, 2021
Copy link
Contributor

@sywhang sywhang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@abhinav abhinav merged commit 9367581 into master Dec 8, 2021
8 checks passed
@abhinav abhinav deleted the abg/sampler-zero branch December 8, 2021 21:17
@mholt
Copy link

mholt commented Dec 8, 2021

Thank you! The updated docs and support for M=0 are much clearer to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Sampling core doesn't seem to have any effect
4 participants