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



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

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.



32
33
34
# File 'lib/datadog/tracing/sampling/matcher.rb', line 32

def name
  @name
end

#serviceObject (readonly)

Returns the value of attribute service.



32
33
34
# File 'lib/datadog/tracing/sampling/matcher.rb', line 32

def service
  @service
end

Instance Method Details

#match?(trace) ⇒ Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/datadog/tracing/sampling/matcher.rb', line 44

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