Class: Errsight::Middleware

Inherits:
Object
  • Object
show all
Defined in:
lib/errsight/middleware.rb

Overview

Rack middleware that stores the request_id on the current thread so the Errsight::Logger can tag every log line with it.

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Middleware

Returns a new instance of Middleware.



5
6
7
# File 'lib/errsight/middleware.rb', line 5

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



9
10
11
12
13
14
# File 'lib/errsight/middleware.rb', line 9

def call(env)
  Thread.current[:errsight_request_id] = env["action_dispatch.request_id"] || env["HTTP_X_REQUEST_ID"]
  @app.call(env)
ensure
  Thread.current[:errsight_request_id] = nil
end