class Zipkin::SpanContext

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

Attributes

baggage[R]
parent_id[R]
span_id[R]
trace_id[R]

Public Class Methods

create_from_parent_context(span_context) click to toggle source
# File lib/zipkin/span_context.rb, line 12
def self.create_from_parent_context(span_context)
  new(
    span_id: TraceId.generate,
    parent_id: span_context.span_id,
    trace_id: span_context.trace_id,
    sampled: span_context.sampled?
  )
end
create_parent_context(sampler = Samplers::Const.new(true)) click to toggle source
# File lib/zipkin/span_context.rb, line 6
def self.create_parent_context(sampler = Samplers::Const.new(true))
  trace_id = TraceId.generate
  sampled = sampler.sample?(trace_id: trace_id)
  new(trace_id: trace_id, span_id: trace_id, sampled: sampled)
end
new(span_id:, parent_id: nil, trace_id:, sampled:, baggage: {}) click to toggle source
# File lib/zipkin/span_context.rb, line 23
def initialize(span_id:, parent_id: nil, trace_id:, sampled:, baggage: {})
  @span_id = span_id
  @parent_id = parent_id
  @trace_id = trace_id
  @sampled = sampled
  @baggage = baggage
end

Public Instance Methods

sampled?() click to toggle source
# File lib/zipkin/span_context.rb, line 31
def sampled?
  @sampled
end
to_h() click to toggle source

NOTE: This method is not defined in OpenTracing Ruby spec. Use with caution.

# File lib/zipkin/span_context.rb, line 37
def to_h
  {
    span_id: @span_id,
    parent_id: @parent_id,
    trace_id: @trace_id,
    sampled: @sampled
  }
end