Class: Datadog::Tracing::Sampling::Span::Matcher
- Inherits:
-
Object
- Object
- Datadog::Tracing::Sampling::Span::Matcher
- Defined in:
- lib/datadog/tracing/sampling/span/matcher.rb
Overview
Checks if a span conforms to a matching criteria.
Constant Summary collapse
- MATCH_ALL_PATTERN =
Pattern that matches any string
'*'
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#service ⇒ Object
readonly
Returns the value of attribute service.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(name_pattern: MATCH_ALL_PATTERN, service_pattern: MATCH_ALL_PATTERN) ⇒ Matcher
constructor
Matches span name and service to their respective patterns provided.
-
#match?(span) ⇒ Boolean
DEV: Remove when support for Ruby 2.3 and older is removed.
Constructor Details
#initialize(name_pattern: MATCH_ALL_PATTERN, service_pattern: MATCH_ALL_PATTERN) ⇒ Matcher
Matches span name and service to their respective patterns provided.
The patterns are Strings with two special characters available:
-
‘?`: matches exactly one of any character.
-
‘*`: matches a substring of any size, including zero.
These patterns can occur any point of the string, any number of times.
Both Datadog::Tracing::SpanOperation#name and Datadog::Tracing::SpanOperation#service must match the provided patterns.
The whole String has to match the provided patterns: providing a pattern that matches a portion of the provided String is not considered a match.
33 34 35 36 |
# File 'lib/datadog/tracing/sampling/span/matcher.rb', line 33 def initialize(name_pattern: MATCH_ALL_PATTERN, service_pattern: MATCH_ALL_PATTERN) @name = pattern_to_regex(name_pattern) @service = pattern_to_regex(service_pattern) end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
9 10 11 |
# File 'lib/datadog/tracing/sampling/span/matcher.rb', line 9 def name @name end |
#service ⇒ Object (readonly)
Returns the value of attribute service.
9 10 11 |
# File 'lib/datadog/tracing/sampling/span/matcher.rb', line 9 def service @service end |
Instance Method Details
#==(other) ⇒ Object
59 60 61 62 63 64 |
# File 'lib/datadog/tracing/sampling/span/matcher.rb', line 59 def ==(other) return super unless other.is_a?(Matcher) name == other.name && service == other.service end |
#match?(span) ⇒ Boolean
DEV: Remove when support for Ruby 2.3 and older is removed.
47 48 49 50 51 |
# File 'lib/datadog/tracing/sampling/span/matcher.rb', line 47 def match?(span) # Matching is performed at the end of the lifecycle of a Span, # thus both `name` and `service` are guaranteed to be not `nil`. @name.match?(span.name) && @service.match?(span.service) end |