Class: OpenTelemetry::SDK::Trace::Samplers::ProbabilitySampler Private
- Inherits:
-
Object
- Object
- OpenTelemetry::SDK::Trace::Samplers::ProbabilitySampler
- Defined in:
- lib/opentelemetry/sdk/trace/samplers/probability_sampler.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Implements sampling based on a probability.
Instance Method Summary collapse
-
#call(trace_id:, span_id:, parent_context:, hint:, links:, name:, kind:, attributes:) ⇒ Object
private
Callable interface for probability sampler.
-
#initialize(probability, ignore_hints:, ignore_parent:, apply_to_remote_parent:, apply_to_all_spans:) ⇒ ProbabilitySampler
constructor
private
A new instance of ProbabilitySampler.
Constructor Details
#initialize(probability, ignore_hints:, ignore_parent:, apply_to_remote_parent:, apply_to_all_spans:) ⇒ ProbabilitySampler
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of ProbabilitySampler.
20 21 22 23 24 25 26 27 |
# File 'lib/opentelemetry/sdk/trace/samplers/probability_sampler.rb', line 20 def initialize(probability, ignore_hints:, ignore_parent:, apply_to_remote_parent:, apply_to_all_spans:) @probability = probability @id_upper_bound = format('%016x', (probability * (2**64 - 1)).ceil) @ignored_hints = ignore_hints @use_parent_sampled_flag = !ignore_parent @apply_to_remote_parent = apply_to_remote_parent @apply_to_all_spans = apply_to_all_spans end |
Instance Method Details
#call(trace_id:, span_id:, parent_context:, hint:, links:, name:, kind:, attributes:) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Callable interface for probability sampler. See OpenTelemetry::SDK::Trace::Samplers.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/opentelemetry/sdk/trace/samplers/probability_sampler.rb', line 32 def call(trace_id:, span_id:, parent_context:, hint:, links:, name:, kind:, attributes:) # Ignored for sampling decision: links, name, kind, attributes. hint = nil if @ignored_hints.include?(hint) sampled = sample?(hint, trace_id, parent_context) recording = hint == HINT_RECORD || sampled if sampled && recording RECORD_AND_SAMPLED elsif recording RECORD else NOT_RECORD end end |