Sha256: b1513ec042550cbeec010355a873874d2e8c501b9a211d895fdcaea263387684

Contents?: true

Size: 1.04 KB

Versions: 10

Compression:

Stored size: 1.04 KB

Contents

# frozen_string_literal: true

module Datadog
  module Tracing
    module Sampling
      # Interface for client-side trace sampling.
      # @abstract
      class Sampler
        # Returns `true` if the provided trace should be kept.
        # Otherwise, `false`.
        #
        # This method *may* modify the `trace`, in case changes are necessary based on the
        # sampling decision.
        #
        # @param [Datadog::Tracing::TraceOperation] trace
        # @return [Boolean] should this trace be kept?
        def sample!(trace)
          raise NotImplementedError, 'Samplers must implement the #sample! method'
        end

        # The sampling rate, if this sampler has such concept.
        # Otherwise, `nil`.
        #
        # @param [Datadog::Tracing::TraceOperation] trace
        # @return [Float,nil] sampling ratio between 0.0 and 1.0 (inclusive), or `nil` if not applicable
        def sample_rate(trace)
          raise NotImplementedError, 'Samplers must implement the #sample_rate method'
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
datadog-2.7.0 lib/datadog/tracing/sampling/sampler.rb
datadog-2.6.0 lib/datadog/tracing/sampling/sampler.rb
datadog-2.5.0 lib/datadog/tracing/sampling/sampler.rb
datadog-2.4.0 lib/datadog/tracing/sampling/sampler.rb
datadog-2.3.0 lib/datadog/tracing/sampling/sampler.rb
datadog-2.2.0 lib/datadog/tracing/sampling/sampler.rb
datadog-2.1.0 lib/datadog/tracing/sampling/sampler.rb
datadog-2.0.0 lib/datadog/tracing/sampling/sampler.rb
datadog-2.0.0.beta2 lib/datadog/tracing/sampling/sampler.rb
datadog-2.0.0.beta1 lib/datadog/tracing/sampling/sampler.rb