Class: OpenTelemetry::Sampler::XRay::FallbackSampler
- Inherits:
-
Object
- Object
- OpenTelemetry::Sampler::XRay::FallbackSampler
- Defined in:
- lib/opentelemetry/sampler/xray/fallback_sampler.rb
Overview
FallbackSampler samples 1 req/sec and additional 5% of requests using TraceIdRatioBasedSampler.
Instance Method Summary collapse
- #description ⇒ Object
-
#initialize ⇒ FallbackSampler
constructor
A new instance of FallbackSampler.
- #should_sample?(trace_id:, parent_context:, links:, name:, kind:, attributes:) ⇒ Boolean
Constructor Details
#initialize ⇒ FallbackSampler
Returns a new instance of FallbackSampler.
14 15 16 17 |
# File 'lib/opentelemetry/sampler/xray/fallback_sampler.rb', line 14 def initialize @fixed_rate_sampler = OpenTelemetry::SDK::Trace::Samplers::TraceIdRatioBased.new(0.05) @rate_limiting_sampler = RateLimitingSampler.new(1) end |
Instance Method Details
#description ⇒ Object
29 30 31 |
# File 'lib/opentelemetry/sampler/xray/fallback_sampler.rb', line 29 def description 'FallbackSampler{fallback sampling with sampling config of 1 req/sec and 5% of additional requests}' end |
#should_sample?(trace_id:, parent_context:, links:, name:, kind:, attributes:) ⇒ Boolean
19 20 21 22 23 24 25 26 27 |
# File 'lib/opentelemetry/sampler/xray/fallback_sampler.rb', line 19 def should_sample?(trace_id:, parent_context:, links:, name:, kind:, attributes:) sampling_result = @rate_limiting_sampler.should_sample?( trace_id: trace_id, parent_context: parent_context, links: links, name: name, kind: kind, attributes: attributes ) return sampling_result if sampling_result.instance_variable_get(:@decision) != OpenTelemetry::SDK::Trace::Samplers::Decision::DROP @fixed_rate_sampler.should_sample?(trace_id: trace_id, parent_context: parent_context, links: links, name: name, kind: kind, attributes: attributes) end |