Class: OpenTelemetry::SDK::Trace::Samplers::ConstantSampler Private

Inherits:
Object
  • Object
show all
Defined in:
lib/opentelemetry/sdk/trace/samplers/constant_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 a sampler returning a result with a constant decision.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(decision:, description:) ⇒ ConstantSampler

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



17
18
19
20
# File 'lib/opentelemetry/sdk/trace/samplers/constant_sampler.rb', line 17

def initialize(decision:, description:)
  @decision = decision
  @description = description
end

Instance Attribute Details

#descriptionObject (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/constant_sampler.rb', line 15

def description
  @description
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.



22
23
24
# File 'lib/opentelemetry/sdk/trace/samplers/constant_sampler.rb', line 22

def ==(other)
  @decision == other.decision && @description == other.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)


29
30
31
# File 'lib/opentelemetry/sdk/trace/samplers/constant_sampler.rb', line 29

def should_sample?(trace_id:, parent_context:, links:, name:, kind:, attributes:)
  Result.new(decision: @decision, tracestate: OpenTelemetry::Trace.current_span(parent_context).context.tracestate)
end