Sha256: 0e47d1559d726a17b64c34324fcd7eea08a1b9b05033cac8b7678263bef8bdb5

Contents?: true

Size: 616 Bytes

Versions: 3

Compression:

Stored size: 616 Bytes

Contents

require 'imprint/version'
require 'imprint/middleware'

module Imprint
  class Tracer
    TRACER_HEADER = 'HTTP_IMPRINTID'
    TRACER_KEY    = 'IMPRINTID'

    TRACE_CHARS = [('a'..'z'), ('A'..'Z')].map { |i| i.to_a }.flatten

    def self.set_trace_id(id, rack_env = {})
      Thread.current[TRACER_KEY] = id
      # setting to the rack_env, gives error tracking support in some systems
      rack_env[TRACER_KEY] = id
    end

    def self.get_trace_id
      Thread.current[TRACER_KEY]
    end

    def self.rand_trace_id
      (0...6).map { TRACE_CHARS[rand(TRACE_CHARS.length)] }.join    
    end
    
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
imprint-1.1.2 lib/imprint.rb
imprint-1.1.1 lib/imprint.rb
imprint-1.1.0 lib/imprint.rb