Class: Trace::TraceId128Bit
Constant Summary
collapse
- HEX_REGEX_16 =
/^[a-f0-9]{16}$/i
- HEX_REGEX_32 =
/^[a-f0-9]{32}$/i
- MAX_SIGNED_I128 =
(2 ** 128 / 2) -1
- MASK =
(2 ** 128) - 1
Constants inherited
from SpanId
SpanId::HEX_REGEX, SpanId::MAX_SIGNED_I64
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of TraceId128Bit.
154
155
156
157
158
159
160
161
|
# File 'lib/zipkin-tracer/trace.rb', line 154
def initialize(value)
@value = value
@i128 = if @value > MAX_SIGNED_I128
-1 * ((@value ^ MASK) + 1)
else
@value
end
end
|
Class Method Details
.from_value(v) ⇒ Object
142
143
144
145
146
147
148
149
150
151
152
|
# File 'lib/zipkin-tracer/trace.rb', line 142
def self.from_value(v)
if v.is_a?(String) && v =~ HEX_REGEX_16
SpanId.new(v.hex)
elsif v.is_a?(String) && v =~ HEX_REGEX_32
new(v.hex)
elsif v.is_a?(Numeric)
new(v)
elsif v.is_a?(SpanId)
v
end
end
|
Instance Method Details
#to_i ⇒ Object
164
|
# File 'lib/zipkin-tracer/trace.rb', line 164
def to_i; @i128; end
|
#to_s ⇒ Object
163
|
# File 'lib/zipkin-tracer/trace.rb', line 163
def to_s; '%032x' % @value; end
|