lib/opentelemetry/sdk/trace/samplers/probability_sampler.rb in opentelemetry-sdk-0.5.0 vs lib/opentelemetry/sdk/trace/samplers/probability_sampler.rb in opentelemetry-sdk-0.5.1

- old
+ new

@@ -14,11 +14,11 @@ class ProbabilitySampler attr_reader :description def initialize(probability, ignore_parent:, apply_to_remote_parent:, apply_to_all_spans:) @probability = probability - @id_upper_bound = format('%016x', (probability * (2**64 - 1)).ceil) + @id_upper_bound = (probability * (2**64 - 1)).ceil @use_parent_sampled_flag = !ignore_parent @apply_to_remote_parent = apply_to_remote_parent @apply_to_all_spans = apply_to_all_spans @description = format('ProbabilitySampler{%.6f}', probability) end @@ -53,10 +53,10 @@ def sample_trace_id_for_child?(parent_context, trace_id) (@apply_to_all_spans || (@apply_to_remote_parent && parent_context.remote?)) && sample_trace_id?(trace_id) end def sample_trace_id?(trace_id) - @probability == 1.0 || trace_id[16, 16] < @id_upper_bound + @probability == 1.0 || trace_id[8, 8].unpack1('Q>') < @id_upper_bound end end end end end