class Honeycomb::Context

Stores the current span and trace context

Public Instance Methods

current_span() click to toggle source
# File lib/honeycomb/context.rb, line 12
def current_span
  spans.last
end
current_span=(span) click to toggle source
# File lib/honeycomb/context.rb, line 16
def current_span=(span)
  spans << span
end
current_trace() click to toggle source
# File lib/honeycomb/context.rb, line 6
def current_trace
  return if current_span.nil?

  current_span.trace
end
span_sent(span) click to toggle source
# File lib/honeycomb/context.rb, line 20
def span_sent(span)
  spans.last != span && raise(ArgumentError, "Incorrect span sent")

  spans.pop
end

Private Instance Methods

spans() click to toggle source
# File lib/honeycomb/context.rb, line 28
def spans
  storage["spans"] ||= []
end
storage() click to toggle source
# File lib/honeycomb/context.rb, line 32
def storage
  Thread.current[thread_key] ||= {}
end
thread_key() click to toggle source
# File lib/honeycomb/context.rb, line 36
def thread_key
  @thread_key ||= ["honeycomb", self.class.name, object_id].join("-")
end