Sample implements the Sampler interface.
(lvl Level)
| 75 | |
| 76 | // Sample implements the Sampler interface. |
| 77 | func (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 | |
| 89 | func (s *BurstSampler) inc() uint32 { |
| 90 | now := TimestampFunc().UnixNano() |