MCPcopy
hub / github.com/rs/zerolog / Sample

Method Sample

sampler.go:77–87  ·  sampler.go::BurstSampler.Sample

Sample implements the Sampler interface.

(lvl Level)

Source from the content-addressed store, hash-verified

75
76// Sample implements the Sampler interface.
77func (s *BurstSampler) Sample(lvl Level) bool {
78 if s.Burst > 0 && s.Period > 0 {
79 if s.inc() <= s.Burst {
80 return true
81 }
82 }
83 if s.NextSampler == nil {
84 return false
85 }
86 return s.NextSampler.Sample(lvl)
87}
88
89func (s *BurstSampler) inc() uint32 {
90 now := TimestampFunc().UnixNano()

Callers 1

TestBurstFunction · 0.95

Calls 2

incMethod · 0.95
SampleMethod · 0.65

Tested by 1

TestBurstFunction · 0.76