Class: OpenTelemetry::SDK::Trace::Samplers::ParentOrElse Private

Inherits:
Object
  • Object
show all
Defined in:
lib/opentelemetry/sdk/trace/samplers/parent_or_else.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. It either respects the parent span's sampling decision or delegates to delegate_sampler for root spans.

Instance Method Summary collapse

Constructor Details

#initialize(delegate_sampler) ⇒ ParentOrElse

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 ParentOrElse.



16
17
18
# File 'lib/opentelemetry/sdk/trace/samplers/parent_or_else.rb', line 16

def initialize(delegate_sampler)
  @delegate_sampler = delegate_sampler
end

Instance Method Details

#descriptionObject

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.

See OpenTelemetry::SDK::Trace::Samplers.



23
24
25
# File 'lib/opentelemetry/sdk/trace/samplers/parent_or_else.rb', line 23

def description
  "ParentOrElse{#{@delegate_sampler.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.

See OpenTelemetry::SDK::Trace::Samplers.

Returns:

  • (Boolean)


30
31
32
33
34
35
36
37
38
# File 'lib/opentelemetry/sdk/trace/samplers/parent_or_else.rb', line 30

def should_sample?(trace_id:, parent_context:, links:, name:, kind:, attributes:)
  if parent_context.nil?
    @delegate_sampler.should_sample?(trace_id: trace_id, parent_context: parent_context, links: links, name: name, kind: kind, attributes: attributes)
  elsif parent_context.trace_flags.sampled?
    RECORD_AND_SAMPLED
  else
    NOT_RECORD
  end
end