Sha256: 198d6788bc9bd2b02e4c4f73fab5db8bb4944a167bd843b64d4f644b07f04a47

Contents?: true

Size: 466 Bytes

Versions: 3

Compression:

Stored size: 466 Bytes

Contents

module Imprint
  class Middleware
    
    def self.set_request_trace_id(rack_env)
      existing_id = rack_env[Imprint::Tracer::TRACER_HEADER]
      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

3 entries across 3 versions & 1 rubygems

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