zap
zap copied to clipboard
Allow thereafter in sampler to be zero
When creating a new Sampler, there is nothing stopping us from passing in 0 as a value for thereafter. One might expect this to be legal -- as the documentation doesn't say thereafter should be greater than zero and no error is returned when passing in this configuration -- and to mean "drop all messages after the first n". What actually happens is a
panic: runtime error: integer divide by zero
when we try to log a message.
This patch avoids the division by zero and enforces the behavior described above.
This fixes issue 632.
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
Gunnar Þór Magnússon seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.
Codecov Report
Merging #633 into master will not change coverage. The diff coverage is
100%
.
@@ Coverage Diff @@
## master #633 +/- ##
=======================================
Coverage 97.38% 97.38%
=======================================
Files 40 40
Lines 2102 2102
=======================================
Hits 2047 2047
Misses 47 47
Partials 8 8
Impacted Files | Coverage Δ | |
---|---|---|
zapcore/sampler.go | 100% <100%> (ø) |
:arrow_up: |
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 67bc79d...3392ebd. Read the comment docs.
since using 0 means we're disabling sampling.
Did I miss where we can choose to log only the first first
messages?