Class: Datadog::Tracing::Sampling::SimpleRule
- Defined in:
- lib/datadog/tracing/sampling/rule.rb
Overview
A Rule that matches a trace based on trace name and/or service name and applies a fixed sampling to matching spans.
Constant Summary
Constants inherited from Rule
Rule::PROVENANCE_LOCAL, Rule::PROVENANCE_REMOTE_DYNAMIC, Rule::PROVENANCE_REMOTE_USER
Instance Attribute Summary
Attributes inherited from Rule
#matcher, #provenance, #sampler
Instance Method Summary collapse
-
#initialize(name: SimpleMatcher::MATCH_ALL_PATTERN, service: SimpleMatcher::MATCH_ALL_PATTERN, resource: SimpleMatcher::MATCH_ALL_PATTERN, tags: {}, provenance: Rule::PROVENANCE_LOCAL, sample_rate: 1.0) ⇒ SimpleRule
constructor
A new instance of SimpleRule.
Methods inherited from Rule
#match?, #sample!, #sample_rate
Constructor Details
#initialize(name: SimpleMatcher::MATCH_ALL_PATTERN, service: SimpleMatcher::MATCH_ALL_PATTERN, resource: SimpleMatcher::MATCH_ALL_PATTERN, tags: {}, provenance: Rule::PROVENANCE_LOCAL, sample_rate: 1.0) ⇒ SimpleRule
Returns a new instance of SimpleRule.
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/datadog/tracing/sampling/rule.rb', line 64 def initialize( name: SimpleMatcher::MATCH_ALL_PATTERN, service: SimpleMatcher::MATCH_ALL_PATTERN, resource: SimpleMatcher::MATCH_ALL_PATTERN, tags: {}, provenance: Rule::PROVENANCE_LOCAL, sample_rate: 1.0 ) # We want to allow 0.0 to drop all traces, but {Datadog::Tracing::Sampling::RateSampler} # considers 0.0 an invalid rate and falls back to 100% sampling. # # We address that here by not setting the rate in the constructor, # but using the setter method. # # We don't want to make this change directly to {Datadog::Tracing::Sampling::RateSampler} # because it breaks its current contract to existing users. sampler = RateSampler.new sampler.sample_rate = sample_rate super(SimpleMatcher.new(name: name, service: service, resource: resource, tags: ), sampler, provenance) end |