Class: Serf::Middleware::RequestTimer
- Inherits:
-
Object
- Object
- Serf::Middleware::RequestTimer
- Defined in:
- lib/serf/middleware/request_timer.rb
Overview
Middleware to time the execution of the remaining stack, saving the timing into the ‘serf_elapsed_time’ field in the parcel.
Defined Under Namespace
Classes: Timer
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#timer ⇒ Object
readonly
Returns the value of attribute timer.
Instance Method Summary collapse
- #call(parcel) ⇒ Object
-
#initialize(app, *args) ⇒ RequestTimer
constructor
A new instance of RequestTimer.
Constructor Details
#initialize(app, *args) ⇒ RequestTimer
Returns a new instance of RequestTimer.
13 14 15 16 17 |
# File 'lib/serf/middleware/request_timer.rb', line 13 def initialize(app, *args) opts = Optser. args @app = app @timer = opts.get :timer, Serf::Middleware::RequestTimer::Timer end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
10 11 12 |
# File 'lib/serf/middleware/request_timer.rb', line 10 def app @app end |
#timer ⇒ Object (readonly)
Returns the value of attribute timer.
11 12 13 |
# File 'lib/serf/middleware/request_timer.rb', line 11 def timer @timer end |
Instance Method Details
#call(parcel) ⇒ Object
19 20 21 22 23 24 |
# 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 |