class Datadog::Sampling::Rule

Sampling rule that dictates if a span matches a specific criteria and what sampling strategy to apply in case of a positive match.

Attributes

matcher[R]
sampler[R]

Public Class Methods

new(matcher, sampler) click to toggle source

@param [Matcher] matcher A matcher to verify span conformity against @param [Sampler] sampler A sampler to be consulted on a positive match

# File lib/ddtrace/sampling/rule.rb, line 19
def initialize(matcher, sampler)
  @matcher = matcher
  @sampler = sampler
end

Public Instance Methods

match?(span) click to toggle source

Evaluates if the provided `span` conforms to the `matcher`.

@param [Span] span @return [Boolean] whether this rules applies to the span @return [NilClass] if the matcher fails errs during evaluation

# File lib/ddtrace/sampling/rule.rb, line 29
def match?(span)
  @matcher.match?(span)
rescue => e
  Datadog.logger.error("Matcher failed. Cause: #{e.message} Source: #{Array(e.backtrace).first}")
  nil
end