Sha256: b0fcb58581702cadbd9e71c2acdc01a3b2c7ef71ccc5f0cb59f1e82fc5573e00

Contents?: true

Size: 513 Bytes

Versions: 6

Compression:

Stored size: 513 Bytes

Contents

module Imprint
  class Middleware
    
    def self.set_request_trace_id(rack_env)
      existing_id = rack_env[Imprint::Tracer::TRACER_HEADER] || rack_env[Imprint::Tracer::RAILS_REQUEST_ID]
      existing_id ||= "#{Time.now.to_i}_#{Imprint::Tracer.rand_trace_id}"
      Imprint::Tracer.set_trace_id(existing_id, rack_env)
    end
    
    def initialize(app, opts = {})
      @app = app
    end
    
    def call(env)
      ::Imprint::Middleware.set_request_trace_id(env)
      @app.call(env)
    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
imprint-1.3.0 lib/imprint/middleware.rb
imprint-1.2.1 lib/imprint/middleware.rb
imprint-1.2.0 lib/imprint/middleware.rb
imprint-1.1.5 lib/imprint/middleware.rb
imprint-1.1.4 lib/imprint/middleware.rb
imprint-1.1.3 lib/imprint/middleware.rb