Sha256: 298f82bbf018bf2d299b9a339c1833ed5c17517e87313b34eae73e6a395c4ad3

Contents?: true

Size: 631 Bytes

Versions: 1

Compression:

Stored size: 631 Bytes

Contents

# frozen_string_literal: true

module Jaeger
  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
        @tags = {
          'sampler.type' => 'probabilistic',
          'sampler.param' => rate
        }
      end

      def sample?(trace_id:, **)
        [@boundary >= trace_id, @tags]
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jaeger-client-0.10.0 lib/jaeger/samplers/probabilistic.rb