Class: Logister::Middleware
- Inherits:
-
Object
- Object
- Logister::Middleware
- Defined in:
- lib/logister/middleware.rb
Constant Summary collapse
- FILTERED_HEADER_PLACEHOLDER =
"[FILTERED]".freeze
- SENSITIVE_HEADERS =
%w[authorization cookie set-cookie x-api-key x-csrf-token].freeze
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ Middleware
constructor
A new instance of Middleware.
Constructor Details
#initialize(app) ⇒ Middleware
Returns a new instance of Middleware.
9 10 11 |
# File 'lib/logister/middleware.rb', line 9 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/logister/middleware.rb', line 13 def call(env) Logister::ContextStore.reset_request_scope! started_at = Process.clock_gettime(Process::CLOCK_MONOTONIC) @app.call(env) rescue StandardError => e request = ActionDispatch::Request.new(env) request_context = build_request_context(request, env, error: e, started_at: started_at) Logister.report_error( e, context: request_context ) raise ensure request_id = env["action_dispatch.request_id"] Logister::ContextStore.clear_request_summary(request_id) Logister::ContextStore.reset_request_scope! end |