lib/jaeger/client/samplers/probabilistic.rb in jaeger-client-0.8.0 vs lib/jaeger/client/samplers/probabilistic.rb in jaeger-client-0.9.0

- old
+ new

@@ -6,25 +6,23 @@ # Probabilistic sampler # # Sample a portion of traces using trace_id as the random decision class Probabilistic def initialize(rate: 0.001) - @param = rate.to_s 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 + @tags = { + 'sampler.type' => 'probabilistic', + 'sampler.param' => rate + } end - def sample?(trace_id) - @boundary >= trace_id + def sample?(trace_id:, **) + [@boundary >= trace_id, @tags] end - - def type - 'probabilistic' - end - - attr_reader :param end end end end