Skip to content

What are the rules on which zap's sampling deduplication is based? #1133

Answered by mway
Super-ZZGuo asked this question in Q&A
Discussion options

You must be logged in to vote

Zap's sampling logic is defined in zapcore/sampler.go as part of the sampler core. At a high level, the way that sampling works is that - for a given log message and its level - determine how many times we've seen that message at that log level within a given period, and evaluate whether we should drop the log based on the sampling config.

The way that it's implemented is:

  1. There are stateful counters per sampler core. The counters establish a number of per-level buckets - currently 4096 buckets for each log level - that we use for tracking periodic state.

  2. zap.SamplingConfig defines two key fields, Initial and Thereafter:

type SamplingConfig struct {
  Initial    int // ...
  Thereafter

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by abhinav
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #1122 on July 21, 2022 15:24.