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.
Instance Attribute Summary
Attributes inherited from Rule
Instance Method Summary collapse
-
#initialize(name: SimpleMatcher::MATCH_ALL, service: SimpleMatcher::MATCH_ALL, resource: SimpleMatcher::MATCH_ALL, tags: {}, 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, service: SimpleMatcher::MATCH_ALL, resource: SimpleMatcher::MATCH_ALL, tags: {}, sample_rate: 1.0) ⇒ SimpleRule
Returns a new instance of SimpleRule.
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/datadog/tracing/sampling/rule.rb', line 57 def initialize( name: SimpleMatcher::MATCH_ALL, service: SimpleMatcher::MATCH_ALL, resource: SimpleMatcher::MATCH_ALL, tags: {}, 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) end |