Class: OpenTelemetry::SDK::Trace::Samplers::ParentBased Private
- Inherits:
-
Object
- Object
- OpenTelemetry::SDK::Trace::Samplers::ParentBased
- Defined in:
- lib/opentelemetry/sdk/trace/samplers/parent_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.
This is a composite sampler. ParentBased helps distinguished between the following cases: * No parent (root span). * Remote parent (SpanContext.remote? with trace_flags.sampled?) * Remote parent (SpanContext.remote? with !trace_flags.sampled?) * Local parent (!SpanContext.remote? with trace_flags.sampled?) * Local parent (!SpanContext.remote? with !trace_flags.sampled?)
Instance Method Summary collapse
- #description ⇒ Object private
-
#initialize(root, remote_parent_sampled, remote_parent_not_sampled, local_parent_sampled, local_parent_not_sampled) ⇒ ParentBased
constructor
private
A new instance of ParentBased.
- #should_sample?(trace_id:, parent_context:, links:, name:, kind:, attributes:) ⇒ Boolean private
Constructor Details
#initialize(root, remote_parent_sampled, remote_parent_not_sampled, local_parent_sampled, local_parent_not_sampled) ⇒ ParentBased
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 ParentBased.
21 22 23 24 25 26 27 |
# File 'lib/opentelemetry/sdk/trace/samplers/parent_based.rb', line 21 def initialize(root, remote_parent_sampled, remote_parent_not_sampled, local_parent_sampled, local_parent_not_sampled) @root = root @remote_parent_sampled = remote_parent_sampled @remote_parent_not_sampled = remote_parent_not_sampled @local_parent_sampled = local_parent_sampled @local_parent_not_sampled = local_parent_not_sampled end |
Instance Method Details
#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.
32 33 34 |
# File 'lib/opentelemetry/sdk/trace/samplers/parent_based.rb', line 32 def description "ParentBased{root=#{@root.description}, remote_parent_sampled=#{@remote_parent_sampled.description}, remote_parent_not_sampled=#{@remote_parent_not_sampled.description}, local_parent_sampled=#{@local_parent_sampled.description}, local_parent_not_sampled=#{@local_parent_not_sampled.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.
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/opentelemetry/sdk/trace/samplers/parent_based.rb', line 39 def should_sample?(trace_id:, parent_context:, links:, name:, kind:, attributes:) parent_span_context = OpenTelemetry::Trace.current_span(parent_context).context delegate = if !parent_span_context.valid? @root elsif parent_span_context.remote? parent_span_context.trace_flags.sampled? ? @remote_parent_sampled : @remote_parent_not_sampled else parent_span_context.trace_flags.sampled? ? @local_parent_sampled : @local_parent_not_sampled end delegate.should_sample?(trace_id: trace_id, parent_context: parent_context, links: links, name: name, kind: kind, attributes: attributes) end |