Sha256: 6f9a462dddabff1b4ada488a3be311562bcced0c11b4d04a2d19f6a2627915cd
Contents?: true
Size: 523 Bytes
Versions: 4
Compression:
Stored size: 523 Bytes
Contents
# frozen_string_literal: true module Zipkin module Samplers # Probabilistic sampler # # Sample a portion of traces using trace_id as the random decision class Probabilistic def initialize(rate: 0.001) if rate < 0.0 || rate > 1.0 raise "Sampling rate must be between 0.0 and 1.0, got #{rate.inspect}" end @boundary = TraceId::TRACE_ID_UPPER_BOUND * rate end def sample?(trace_id:, **) @boundary >= trace_id.to_i(16) end end end end
Version data entries
4 entries across 4 versions & 1 rubygems