Class: Datadog::Tracing::Sampling::Sampler Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/datadog/tracing/sampling/sampler.rb

Overview

This class is abstract.

Interface for client-side trace sampling.

Direct Known Subclasses

AllSampler, RateByKeySampler, RateSampler

Instance Method Summary collapse

Instance Method Details

#sample!(trace) ⇒ Boolean

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.

Parameters:

Returns:

  • (Boolean)

    should this trace be kept?



27
28
29
# File 'lib/datadog/tracing/sampling/sampler.rb', line 27

def sample!(trace)
  raise NotImplementedError, 'Samplers must implement the #sample! method'
end

#sample?(trace) ⇒ Boolean

Returns true if the provided trace should be kept. Otherwise, false.

This method must not modify the trace.

Parameters:

Returns:

  • (Boolean)

    should this trace be kept?



15
16
17
# File 'lib/datadog/tracing/sampling/sampler.rb', line 15

def sample?(trace)
  raise NotImplementedError, 'Samplers must implement the #sample? method'
end

#sample_rate(trace) ⇒ Float?

The sampling rate, if this sampler has such concept. Otherwise, nil.

Parameters:

Returns:

  • (Float, nil)

    sampling ratio between 0.0 and 1.0 (inclusive), or nil if not applicable



36
37
38
# File 'lib/datadog/tracing/sampling/sampler.rb', line 36

def sample_rate(trace)
  raise NotImplementedError, 'Samplers must implement the #sample_rate method'
end