-
I tried reading this part of the code, but didn't find it |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Zap's sampling logic is defined in zapcore/sampler.go as part of the The way that it's implemented is:
type SamplingConfig struct {
Initial int // ...
Thereafter int // ...
// ...
}
logger.Info("foo") // --> info buckets -> "foo" hashes to info bucket 123
logger.Info("bar") // --> info buckets -> "bar" hashes to info bucket 456
logger.Warn("oops") // --> warn buckets -> "oops" hashes to warn bucket 123 Thus no log level can be conflated with the other log levels, and messages within a given level can only be conflated if they are hashed into the same bucket for that level.
The terminology can be a bit confusing, but hopefully that helps clear things up! |
Beta Was this translation helpful? Give feedback.
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:
There are stateful
counters
persampler
core. The counters establish a number of per-level buckets - currently 4096 buckets for each log level - that we use for tracking periodic state.zap.SamplingConfig
defines two key fields,Initial
andThereafter
: