MCPcopy
hub / github.com/uber-go/zap / makeSamplerCountingHook

Function makeSamplerCountingHook

zapcore/sampler_bench_test.go:236–247  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

234}
235
236func makeSamplerCountingHook() (func(_ Entry, dec SamplingDecision), *atomic.Int64, *atomic.Int64) {
237 droppedCount := new(atomic.Int64)
238 sampledCount := new(atomic.Int64)
239 h := func(_ Entry, dec SamplingDecision) {
240 if dec&LogDropped > 0 {
241 droppedCount.Add(1)
242 } else if dec&LogSampled > 0 {
243 sampledCount.Add(1)
244 }
245 }
246 return h, droppedCount, sampledCount
247}
248
249func BenchmarkSampler_CheckWithHook(b *testing.B) {
250 hook, dropped, sampled := makeSamplerCountingHook()

Callers 2

TestSamplerConcurrentFunction · 0.70

Calls 1

AddMethod · 0.45

Tested by

no test coverage detected