Sha256: 523ced7bbef12efe93964a1e0f55fcdc7d959e4f3905ca6fccf51181138c0a50

Contents?: true

Size: 669 Bytes

Versions: 28

Compression:

Stored size: 669 Bytes

Contents

# frozen_string_literal: true

module Honeycomb
  # Stores the current span and trace context
  class Context
    def current_trace
      return if current_span.nil?

      current_span.trace
    end

    def current_span
      spans.last
    end

    def current_span=(span)
      spans << span
    end

    def span_sent(span)
      spans.last != span && raise(ArgumentError, "Incorrect span sent")

      spans.pop
    end

    private

    def spans
      storage["spans"] ||= []
    end

    def storage
      Thread.current[thread_key] ||= {}
    end

    def thread_key
      @thread_key ||= ["honeycomb", self.class.name, object_id].join("-")
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
honeycomb-beeline-2.8.2 lib/honeycomb/context.rb
honeycomb-beeline-2.8.1 lib/honeycomb/context.rb
honeycomb-beeline-2.8.0 lib/honeycomb/context.rb
honeycomb-beeline-2.7.1 lib/honeycomb/context.rb
honeycomb-beeline-2.7.0 lib/honeycomb/context.rb
honeycomb-beeline-2.6.0 lib/honeycomb/context.rb
honeycomb-beeline-2.5.0 lib/honeycomb/context.rb
honeycomb-beeline-2.4.2 lib/honeycomb/context.rb
honeycomb-beeline-2.4.1 lib/honeycomb/context.rb
honeycomb-beeline-2.4.0 lib/honeycomb/context.rb
honeycomb-beeline-2.3.0 lib/honeycomb/context.rb
honeycomb-beeline-2.2.0 lib/honeycomb/context.rb
honeycomb-beeline-2.1.2 lib/honeycomb/context.rb
honeycomb-beeline-2.1.1 lib/honeycomb/context.rb
honeycomb-beeline-2.1.0 lib/honeycomb/context.rb
honeycomb-beeline-2.0.0 lib/honeycomb/context.rb
honeycomb-beeline-1.3.0 lib/honeycomb/context.rb
honeycomb-beeline-1.2.0 lib/honeycomb/context.rb
honeycomb-beeline-1.1.1 lib/honeycomb/context.rb
honeycomb-beeline-1.1.0 lib/honeycomb/context.rb