Class: Datadog::Tracing::Sampling::SimpleMatcher

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

Overview

A Sampling::Matcher that supports matching a trace by trace name and/or service name.

Constant Summary collapse

MATCH_ALL =

Returns ‘true` for case equality (===) with any object

Class.new do
  # DEV: A class that implements `#===` is ~20% faster than
  # DEV: a `Proc` that always returns `true`.
  def ===(other)
    true
  end
end.new

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name: MATCH_ALL, service: MATCH_ALL) ⇒ SimpleMatcher

Returns a new instance of SimpleMatcher.

Parameters:

  • name (String, Regexp, Proc) (defaults to: MATCH_ALL)

    Matcher for case equality (===) with the trace name, defaults to always match

  • service (String, Regexp, Proc) (defaults to: MATCH_ALL)

    Matcher for case equality (===) with the service name, defaults to always match



36
37
38
39
40
# File 'lib/datadog/tracing/sampling/matcher.rb', line 36

def initialize(name: MATCH_ALL, service: MATCH_ALL)
  super()
  @name = name
  @service = service
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



30
31
32
# File 'lib/datadog/tracing/sampling/matcher.rb', line 30

def name
  @name
end

#serviceObject (readonly)

Returns the value of attribute service.



30
31
32
# File 'lib/datadog/tracing/sampling/matcher.rb', line 30

def service
  @service
end

Instance Method Details

#match?(trace) ⇒ Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/datadog/tracing/sampling/matcher.rb', line 42

def match?(trace)
  name === trace.name && service === trace.service
end