class Datadog::Tracing::Sampling::SimpleRule

@public_api
applies a fixed sampling to matching spans.
trace name and/or service name and
A {Datadog::Tracing::Sampling::Rule} that matches a trace based on

def initialize(name: SimpleMatcher::MATCH_ALL, service: SimpleMatcher::MATCH_ALL, sample_rate: 1.0)

Parameters:
  • sample_rate (Float) -- Sampling rate between +[0,1]+
  • service (String, Regexp, Proc) -- Matcher for case equality (===) with the service name,
  • name (String, Regexp, Proc) -- Matcher for case equality (===) with the trace name, defaults to always match
def initialize(name: SimpleMatcher::MATCH_ALL, service: SimpleMatcher::MATCH_ALL, sample_rate: 1.0)
  # We want to allow 0.0 to drop all traces, but {Datadog::Tracing::Sampling::RateSampler}
  # considers 0.0 an invalid rate and falls back to 100% sampling.
  #
  # We address that here by not setting the rate in the constructor,
  # but using the setter method.
  #
  # We don't want to make this change directly to {Datadog::Tracing::Sampling::RateSampler}
  # because it breaks its current contract to existing users.
  sampler = RateSampler.new
  sampler.sample_rate = sample_rate
  super(SimpleMatcher.new(name: name, service: service), sampler)
end