class RequestTracer::Trace::SpanId

A span represents one specific method call

Constants

HEX_REGEX
MASK
MAX_SIGNED_I64

Attributes

i64[R]
value[R]

Public Class Methods

from_value(v) click to toggle source
# File lib/request_tracer/trace.rb, line 21
def self.from_value(v)
  if v.is_a?(String) && v =~ HEX_REGEX
    new(v.hex)
  elsif v.is_a?(Numeric)
    new(v)
  elsif v.is_a?(SpanId)
    v
  end
end
new(value) click to toggle source
# File lib/request_tracer/trace.rb, line 32
def initialize(value)
  @value = value
  @i64 = if @value > MAX_SIGNED_I64
    -1 * ((@value ^ MASK) + 1)
  else
    @value
  end
end

Public Instance Methods

==(other_span) click to toggle source
# File lib/request_tracer/trace.rb, line 41
def ==(other_span)
  other_span && (other_span.value == @value)
end
to_i() click to toggle source
# File lib/request_tracer/trace.rb, line 45
def to_i; @i64; end
to_s() click to toggle source
# File lib/request_tracer/trace.rb, line 44
def to_s; "%016x" % @value; end