class Trace::Context
A generic representation of the current span. We follow the <github.com/openzipkin/b3-propagation> model.
Constants
- SAMPLED
Attributes
flags[R]
span_id[R]
state[R]
trace_id[R]
Public Class Methods
new(trace_id, parent_id, flags, state = nil, remote: false)
click to toggle source
# File lib/trace/context.rb, line 47 def initialize(trace_id, parent_id, flags, state = nil, remote: false) @trace_id = trace_id @parent_id = span_id @flags = flags @state = state @remote = remote end
parse(parent, state = nil)
click to toggle source
# File lib/trace/context.rb, line 27 def self.parse(parent, state = nil) version, trace_id, parent_id, flags = parent.split('-') if version = '00' flags = Integer(trace_flags, 16) if state.is_a?(String) state = state.split(',') end if state state = state.map{|item| item.split('=')} end self.new(trace_id, parent_id, flags, state) end end
Public Instance Methods
remote?()
click to toggle source
# File lib/trace/context.rb, line 64 def remote? @remote end
sampled?()
click to toggle source
# File lib/trace/context.rb, line 60 def sampled? @flags & SAMPLED end
to_s()
click to toggle source
# File lib/trace/context.rb, line 68 def to_s "00-#{@trace_id}-#{@parent_id}-#{@flags.to_s(16)}" end