class Serf::Middleware::RequestTimer

Middleware to time the execution of the remaining stack, saving the timing into the ‘serf_elapsed_time’ field in the parcel.

Attributes

app[R]
timer[R]

Public Class Methods

new(app, *args) click to toggle source
# File lib/serf/middleware/request_timer.rb, line 13
def initialize(app, *args)
  opts = Optser.extract_options! args
  @app = app
  @timer = opts.get :timer, Serf::Middleware::RequestTimer::Timer
end

Public Instance Methods

call(parcel) click to toggle source
# File lib/serf/middleware/request_timer.rb, line 19
def call(parcel)
  t = timer.start
  response_parcel = app.call parcel
  response_parcel[:serf_elapsed_time] = t.mark
  return response_parcel
end