class Dry::Monitor::Rack::Middleware

Constants

REQUEST_ERROR
REQUEST_START
REQUEST_STOP

Attributes

app[R]
notifications[R]

Public Class Methods

new(*args) click to toggle source
# File lib/dry/monitor/rack/middleware.rb, line 19
def initialize(*args)
  @notifications, @app = *args
end

Public Instance Methods

call(env) click to toggle source
# File lib/dry/monitor/rack/middleware.rb, line 35
def call(env)
  notifications.start(REQUEST_START, env: env)
  response, time = CLOCK.measure { app.call(env) }
  notifications.stop(REQUEST_STOP, env: env, time: time, status: response[0])
  response
end
instrument(event_id, *args, &block) click to toggle source
# File lib/dry/monitor/rack/middleware.rb, line 31
def instrument(event_id, *args, &block)
  notifications.instrument(:"rack.request.#{event_id}", *args, &block)
end
new(app, *_args, &_block) click to toggle source
# File lib/dry/monitor/rack/middleware.rb, line 23
def new(app, *_args, &_block)
  self.class.new(notifications, app)
end
on(event_id, &block) click to toggle source
# File lib/dry/monitor/rack/middleware.rb, line 27
def on(event_id, &block)
  notifications.subscribe(:"rack.request.#{event_id}", &block)
end