class Jaeger::Client::SpanContext

SpanContext holds the data for a span that gets inherited to child spans

Constants

ID_ATTRIBUTES
MAX_SIGNED_ID
MAX_UNSIGNED_ID

Attributes

baggage[R]
flags[R]

Public Class Methods

create_from_parent_context(span_context) click to toggle source
# File lib/jaeger/client/span_context.rb, line 24
def self.create_from_parent_context(span_context)
  trace_id = span_context.trace_id
  parent_id = span_context.span_id
  flags = span_context.flags
  span_id = TraceId.generate
  new(span_id: span_id, parent_id: parent_id, trace_id: trace_id, flags: flags)
end
create_parent_context(sampler = Samplers::Const.new(true)) click to toggle source
# File lib/jaeger/client/span_context.rb, line 17
def self.create_parent_context(sampler = Samplers::Const.new(true))
  trace_id = TraceId.generate
  span_id = TraceId.generate
  flags = sampler.sample?(trace_id) ? Flags::SAMPLED : Flags::NONE
  new(trace_id: trace_id, span_id: span_id, flags: flags)
end
new(span_id:, parent_id: 0, trace_id:, flags:, baggage: {}) click to toggle source
# File lib/jaeger/client/span_context.rb, line 40
def initialize(span_id:, parent_id: 0, trace_id:, flags:, baggage: {})
  @span_id = span_id
  @parent_id = parent_id
  @trace_id = trace_id
  @baggage = baggage
  @flags = flags
end

Public Instance Methods

debug?() click to toggle source
# File lib/jaeger/client/span_context.rb, line 52
def debug?
  @flags & Flags::DEBUG == Flags::DEBUG
end
inspect() click to toggle source
# File lib/jaeger/client/span_context.rb, line 56
def inspect
  to_s
end
sampled?() click to toggle source
# File lib/jaeger/client/span_context.rb, line 48
def sampled?
  @flags & Flags::SAMPLED == Flags::SAMPLED
end
to_s() click to toggle source
# File lib/jaeger/client/span_context.rb, line 60
def to_s
  "#<SpanContext @span_id=#{span_id.to_s(16)} " \
    "@parent_id=#{parent_id.to_s(16)} " \
    "@trace_id=#{trace_id.to_s(16)} " \
    "@flags=#{flags}>"
end

Private Instance Methods

id_to_thrift_int(id) click to toggle source
# File lib/jaeger/client/span_context.rb, line 69
def id_to_thrift_int(id)
  return unless id

  id -= MAX_UNSIGNED_ID if id > MAX_SIGNED_ID
  id
end