Sha256: f64879698b5dd491fd69e6f38cc085b6812207564ea8198eea6425b05bdafcaf

Contents?: true

Size: 1.43 KB

Versions: 16

Compression:

Stored size: 1.43 KB

Contents

# typed: true

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

        # 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

16 entries across 16 versions & 1 rubygems

Version Path
ddtrace-1.9.0 lib/datadog/tracing/sampling/sampler.rb
ddtrace-1.8.0 lib/datadog/tracing/sampling/sampler.rb
ddtrace-1.7.0 lib/datadog/tracing/sampling/sampler.rb
ddtrace-1.6.1 lib/datadog/tracing/sampling/sampler.rb
ddtrace-1.6.0 lib/datadog/tracing/sampling/sampler.rb
ddtrace-1.5.2 lib/datadog/tracing/sampling/sampler.rb
ddtrace-1.5.1 lib/datadog/tracing/sampling/sampler.rb
ddtrace-1.5.0 lib/datadog/tracing/sampling/sampler.rb
ddtrace-1.4.2 lib/datadog/tracing/sampling/sampler.rb
ddtrace-1.4.1 lib/datadog/tracing/sampling/sampler.rb
ddtrace-1.4.0 lib/datadog/tracing/sampling/sampler.rb
ddtrace-1.3.0 lib/datadog/tracing/sampling/sampler.rb
ddtrace-1.2.0 lib/datadog/tracing/sampling/sampler.rb
ddtrace-1.1.0 lib/datadog/tracing/sampling/sampler.rb
ddtrace-1.0.0 lib/datadog/tracing/sampling/sampler.rb
ddtrace-1.0.0.beta2 lib/datadog/tracing/sampling/sampler.rb