NewSamplerWithOptions creates a Core that samples incoming entries, which caps the CPU and I/O load of logging while attempting to preserve a representative subset of your logs. Zap samples by logging the first N entries with a given level and message each tick. If more Entries with the same level
(core Core, tick time.Duration, first, thereafter int, opts ...SamplerOption)
| 150 | // absolute precision; under load, each tick may be slightly over- or |
| 151 | // under-sampled. |
| 152 | func NewSamplerWithOptions(core Core, tick time.Duration, first, thereafter int, opts ...SamplerOption) Core { |
| 153 | s := &sampler{ |
| 154 | Core: core, |
| 155 | tick: tick, |
| 156 | counts: newCounters(), |
| 157 | first: uint64(first), |
| 158 | thereafter: uint64(thereafter), |
| 159 | hook: nopSamplingHook, |
| 160 | } |
| 161 | for _, opt := range opts { |
| 162 | opt.apply(s) |
| 163 | } |
| 164 | |
| 165 | return s |
| 166 | } |
| 167 | |
| 168 | type sampler struct { |
| 169 | Core |