Class: OpenTelemetry::SDK::Trace::Samplers::TraceIdRatioBased Private
- Inherits:
-
Object
- Object
- OpenTelemetry::SDK::Trace::Samplers::TraceIdRatioBased
- Defined in:
- lib/opentelemetry/sdk/trace/samplers/trace_id_ratio_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.
Implements sampling based on a probability.
Instance Attribute Summary collapse
- #description ⇒ Object readonly private
Instance Method Summary collapse
- #==(other) ⇒ Object private
-
#initialize(probability) ⇒ TraceIdRatioBased
constructor
private
A new instance of TraceIdRatioBased.
- #should_sample?(trace_id:, parent_context:, links:, name:, kind:, attributes:) ⇒ Boolean private
Constructor Details
#initialize(probability) ⇒ TraceIdRatioBased
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 TraceIdRatioBased.
17 18 19 20 21 |
# File 'lib/opentelemetry/sdk/trace/samplers/trace_id_ratio_based.rb', line 17 def initialize(probability) @probability = probability @id_upper_bound = (probability * (2**64 - 1)).ceil @description = format('TraceIdRatioBased{%.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/trace_id_ratio_based.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.
23 24 25 |
# File 'lib/opentelemetry/sdk/trace/samplers/trace_id_ratio_based.rb', line 23 def ==(other) @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.
30 31 32 33 34 35 36 37 |
# File 'lib/opentelemetry/sdk/trace/samplers/trace_id_ratio_based.rb', line 30 def should_sample?(trace_id:, parent_context:, links:, name:, kind:, attributes:) tracestate = OpenTelemetry::Trace.current_span(parent_context).context.tracestate if sample?(trace_id) Result.new(decision: Decision::RECORD_AND_SAMPLE, tracestate: tracestate) else Result.new(decision: Decision::DROP, tracestate: tracestate) end end |