Class: RailsInstrument::Middleware
- Inherits:
-
Object
- Object
- RailsInstrument::Middleware
- Defined in:
- lib/rails_instrument.rb
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.
5 6 7 |
# File 'lib/rails_instrument.rb', line 5 def initialize(app, = {}) @app = app end |
Instance Method Details
#call(env) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/rails_instrument.rb', line 9 def call(env) $rails_instrument = {} status, headers, body = @app.call(env) begin headers["X-View-Runtime"] = ($rails_instrument["process_action.action_controller"][:view_runtime] / 1000).to_s headers["X-DB-Runtime"] = ($rails_instrument["process_action.action_controller"][:db_runtime] / 1000).to_s headers["X-DB-Query-Count"] = $rails_instrument[:sql_count].to_s rescue # Do nothing end [status, headers, body] end |