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 Attribute Summary collapse
- #description ⇒ Object readonly private
Instance Method Summary collapse
-
#initialize(probability, ignore_parent:, apply_to_remote_parent:, apply_to_all_spans:) ⇒ ProbabilitySampler
constructor
private
A new instance of ProbabilitySampler.
- #should_sample?(trace_id:, parent_context:, links:, name:, kind:, attributes:) ⇒ Boolean private
Constructor Details
#initialize(probability, 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.
17 18 19 20 21 22 23 24 |
# File 'lib/opentelemetry/sdk/trace/samplers/probability_sampler.rb', line 17 def initialize(probability, ignore_parent:, apply_to_remote_parent:, apply_to_all_spans:) @probability = probability @id_upper_bound = format('%016x', (probability * (2**64 - 1)).ceil) @use_parent_sampled_flag = !ignore_parent @apply_to_remote_parent = apply_to_remote_parent @apply_to_all_spans = apply_to_all_spans @description = format('ProbabilitySampler{%.6f}', probability) end |
Instance Attribute Details
#description ⇒ Object (readonly)
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.
15 16 17 |
# File 'lib/opentelemetry/sdk/trace/samplers/probability_sampler.rb', line 15 def description @description end |
Instance Method Details
#should_sample?(trace_id:, parent_context:, links:, name:, kind:, attributes:) ⇒ Boolean
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.
29 30 31 32 33 34 35 36 37 |
# File 'lib/opentelemetry/sdk/trace/samplers/probability_sampler.rb', line 29 def should_sample?(trace_id:, parent_context:, links:, name:, kind:, attributes:) # Ignored for sampling decision: links, name, kind, attributes. if sample?(trace_id, parent_context) RECORD_AND_SAMPLED else NOT_RECORD end end |