Class: Datadog::Tracing::Sampling::SimpleMatcher
- 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
Constants inherited from Matcher
Matcher::MATCH_ALL, Matcher::MATCH_ALL_PATTERN
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#resource ⇒ Object
readonly
Returns the value of attribute resource.
-
#service ⇒ Object
readonly
Returns the value of attribute service.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
Instance Method Summary collapse
-
#initialize(name: MATCH_ALL_PATTERN, service: MATCH_ALL_PATTERN, resource: MATCH_ALL_PATTERN, tags: {}) ⇒ SimpleMatcher
constructor
A new instance of SimpleMatcher.
- #match?(trace) ⇒ Boolean
Methods inherited from Matcher
Constructor Details
#initialize(name: MATCH_ALL_PATTERN, service: MATCH_ALL_PATTERN, resource: MATCH_ALL_PATTERN, tags: {}) ⇒ SimpleMatcher
Returns a new instance of SimpleMatcher.
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/datadog/tracing/sampling/matcher.rb', line 70 def initialize( name: MATCH_ALL_PATTERN, service: MATCH_ALL_PATTERN, resource: MATCH_ALL_PATTERN, tags: {} ) super() name = Matcher.glob_to_regex(name) service = Matcher.glob_to_regex(service) resource = Matcher.glob_to_regex(resource) = .transform_values { |matcher| Matcher.glob_to_regex(matcher) } @name = name || Datadog::Tracing::Sampling::Matcher::MATCH_ALL @service = service || Datadog::Tracing::Sampling::Matcher::MATCH_ALL @resource = resource || Datadog::Tracing::Sampling::Matcher::MATCH_ALL @tags = end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
62 63 64 |
# File 'lib/datadog/tracing/sampling/matcher.rb', line 62 def name @name end |
#resource ⇒ Object (readonly)
Returns the value of attribute resource.
62 63 64 |
# File 'lib/datadog/tracing/sampling/matcher.rb', line 62 def resource @resource end |
#service ⇒ Object (readonly)
Returns the value of attribute service.
62 63 64 |
# File 'lib/datadog/tracing/sampling/matcher.rb', line 62 def service @service end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
62 63 64 |
# File 'lib/datadog/tracing/sampling/matcher.rb', line 62 def @tags end |
Instance Method Details
#match?(trace) ⇒ Boolean
89 90 91 92 93 94 |
# File 'lib/datadog/tracing/sampling/matcher.rb', line 89 def match?(trace) @name.match?(trace.name) && @service.match?(trace.service) && @resource.match?(trace.resource) && (trace) end |