Optimize basic sampler
This commit is contained in:
parent
ad0401954a
commit
ffd0e9625d
|
@ -46,8 +46,12 @@ type BasicSampler struct {
|
||||||
|
|
||||||
// Sample implements the Sampler interface.
|
// Sample implements the Sampler interface.
|
||||||
func (s *BasicSampler) Sample(lvl Level) bool {
|
func (s *BasicSampler) Sample(lvl Level) bool {
|
||||||
|
n := s.N
|
||||||
|
if n == 1 {
|
||||||
|
return true
|
||||||
|
}
|
||||||
c := atomic.AddUint32(&s.counter, 1)
|
c := atomic.AddUint32(&s.counter, 1)
|
||||||
return c%s.N == s.N-1
|
return c%n == 1
|
||||||
}
|
}
|
||||||
|
|
||||||
// BurstSampler lets Burst events pass per Period then pass the decision to
|
// BurstSampler lets Burst events pass per Period then pass the decision to
|
||||||
|
|
Loading…
Reference in New Issue