module Honeycomb::DeterministicSampler
Provides a should_sample
method which can be used for deterministic sampling
Constants
- MAX_INT32
Public Instance Methods
should_sample(rate, value)
click to toggle source
# File lib/honeycomb/deterministic_sampler.rb, line 13 def should_sample(rate, value) return true if rate == 1 upper_bound = MAX_INT32 / rate digest = Digest::SHA1.digest(value)[0, 4] value = digest.unpack("I!>").first value <= upper_bound end