Class: Datadog::Tracing::Sampling::RateByServiceSampler
- Inherits:
-
RateByKeySampler
- Object
- Sampler
- RateByKeySampler
- Datadog::Tracing::Sampling::RateByServiceSampler
- Defined in:
- lib/datadog/tracing/sampling/rate_by_service_sampler.rb
Overview
RateByServiceSampler samples different services at different rates
Constant Summary collapse
- DEFAULT_KEY =
'service:,env:'
Instance Attribute Summary
Attributes inherited from RateByKeySampler
Instance Method Summary collapse
-
#initialize(default_rate = 1.0, env: nil, decision: Datadog::Tracing::Sampling::Ext::Decision::DEFAULT) ⇒ RateByServiceSampler
constructor
A new instance of RateByServiceSampler.
- #update(rate_by_service, decision: nil) ⇒ Object
Methods inherited from RateByKeySampler
#default_sampler, #delete, #delete_if, #length, #resolve, #sample!, #sample_rate, #update_all
Methods inherited from Sampler
Constructor Details
#initialize(default_rate = 1.0, env: nil, decision: Datadog::Tracing::Sampling::Ext::Decision::DEFAULT) ⇒ RateByServiceSampler
Returns a new instance of RateByServiceSampler.
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/datadog/tracing/sampling/rate_by_service_sampler.rb', line 12 def initialize(default_rate = 1.0, env: nil, decision: Datadog::Tracing::Sampling::Ext::Decision::DEFAULT) super( DEFAULT_KEY, default_rate, decision: decision, &method(:key_for) ) @env = env end |
Instance Method Details
#update(rate_by_service, decision: nil) ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/datadog/tracing/sampling/rate_by_service_sampler.rb', line 23 def update(rate_by_service, decision: nil) # Remove any old services delete_if { |key, _| key != DEFAULT_KEY && !rate_by_service.key?(key) } # Update each service rate update_all(rate_by_service, decision: decision) # Emit metric for service cache size Datadog.health_metrics.sampling_service_cache_length(length) end |