lib/opentelemetry/sdk/trace/samplers/consistent_probability_tracestate.rb in opentelemetry-sdk-experimental-0.2.0 vs lib/opentelemetry/sdk/trace/samplers/consistent_probability_tracestate.rb in opentelemetry-sdk-experimental-0.3.0
- old
+ new
@@ -11,11 +11,11 @@
# @api private
#
# The ConsistentProbabilityTraceState module implements Tracestate parsing,
# validation and manipulation for the consistent probability-based samplers.
module ConsistentProbabilityTraceState
- DECIMAL = /\A\d+\z/.freeze
+ DECIMAL = /\A\d+\z/
MAX_LIST_LENGTH = 256 # Defined by https://www.w3.org/TR/trace-context/
private_constant(:DECIMAL, :MAX_LIST_LENGTH)
private
@@ -75,11 +75,11 @@
end
rest = nil if rest.empty?
yield(p, r, rest)
end
- def update_tracestate(tracestate, p, r, rest) # rubocop:disable Naming/UncommunicativeMethodParamName
+ def update_tracestate(tracestate, p, r, rest)
if p.nil? && r.nil? && rest.nil?
tracestate.delete('ot')
elsif p.nil? && r.nil?
tracestate.set_value('ot', rest)
elsif p.nil? && rest.nil?
@@ -95,21 +95,20 @@
else
tracestate.set_value('ot', "p:#{p};r:#{r};#{rest}")
end
end
- def invariant(p, r, sampled) # rubocop:disable Naming/UncommunicativeMethodParamName
+ def invariant(p, r, sampled)
((p <= r) == sampled) || (sampled && (p == 63))
end
def decimal(str)
str.to_i if !str.nil? && DECIMAL.match?(str)
end
def generate_r(trace_id)
x = trace_id[8, 8].unpack1('Q>') | 0x3
- clz = 64 - x.bit_length
- clz
+ 64 - x.bit_length
end
end
end
end
end