Class: OpenTelemetry::SDK::Trace::Samplers::ParentConsistentProbabilityBased Private
- Inherits:
-
Object
- Object
- OpenTelemetry::SDK::Trace::Samplers::ParentConsistentProbabilityBased
- Includes:
- ConsistentProbabilityTraceState
- Defined in:
- lib/opentelemetry/sdk/trace/samplers/parent_consistent_probability_based.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.
The ParentConsistentProbabilityBased sampler is meant as an optional replacement for the ParentBased sampler. It is required to first validate the tracestate and then respect the sampled flag in the W3C traceparent.
The ParentConsistentProbabilityBased Sampler constructor takes a single Sampler argument, which is the Sampler to use in case the ParentConsistentProbabilityBased Sampler is called for a root span.
Instance Method Summary collapse
- #==(other) ⇒ Object private
- #description ⇒ Object private
-
#initialize(root) ⇒ ParentConsistentProbabilityBased
constructor
private
A new instance of ParentConsistentProbabilityBased.
- #should_sample?(trace_id:, parent_context:, links:, name:, kind:, attributes:) ⇒ Boolean private
Constructor Details
#initialize(root) ⇒ ParentConsistentProbabilityBased
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 ParentConsistentProbabilityBased.
23 24 25 |
# File 'lib/opentelemetry/sdk/trace/samplers/parent_consistent_probability_based.rb', line 23 def initialize(root) @root = root end |
Instance Method Details
#==(other) ⇒ 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.
27 28 29 |
# File 'lib/opentelemetry/sdk/trace/samplers/parent_consistent_probability_based.rb', line 27 def ==(other) @root == other.root end |
#description ⇒ 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.
34 35 36 |
# File 'lib/opentelemetry/sdk/trace/samplers/parent_consistent_probability_based.rb', line 34 def description "ParentConsistentProbabilityBased{root=#{@root.description}}" end |
#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.
41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/opentelemetry/sdk/trace/samplers/parent_consistent_probability_based.rb', line 41 def should_sample?(trace_id:, parent_context:, links:, name:, kind:, attributes:) parent_span_context = OpenTelemetry::Trace.current_span(parent_context).context if !parent_span_context.valid? @root.should_sample?(trace_id: trace_id, parent_context: parent_context, links: links, name: name, kind: kind, attributes: attributes) else tracestate = sanitized_tracestate(trace_id, parent_span_context) if parent_span_context.trace_flags.sampled? Result.new(decision: Decision::RECORD_AND_SAMPLE, tracestate: tracestate) else Result.new(decision: Decision::DROP, tracestate: tracestate) end end end |