Class: Chronos::Integrations::Rack::Middleware
- Inherits:
-
Object
- Object
- Chronos::Integrations::Rack::Middleware
- Defined in:
- lib/chronos/integrations/rack/middleware.rb
Overview
Captures unhandled Rack exceptions while preserving Rack semantics.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ Middleware
constructor
A new instance of Middleware.
Constructor Details
#initialize(app, options = {}) ⇒ Middleware
Returns a new instance of Middleware.
19 20 21 22 23 24 |
# File 'lib/chronos/integrations/rack/middleware.rb', line 19 def initialize(app, = {}) @app = app @notifier = [:notifier] || Chronos @include_user_agent = [:include_user_agent] || false @clock = [:clock] || proc { monotonic_time } end |
Instance Method Details
#call(env) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/chronos/integrations/rack/middleware.rb', line 26 def call(env) started_at = @clock.call base = request_capture_context(env) @notifier.with_context(base) do ("request started", base) call_application(env, base, started_at) end end |