Class: Metrics::Integration::Rack::Middleware
- Inherits:
-
Object
- Object
- Metrics::Integration::Rack::Middleware
- Defined in:
- lib/ruby-metrics/integration/rack_middleware.rb
Instance Attribute Summary collapse
-
#agent ⇒ Object
Returns the value of attribute agent.
-
#app ⇒ Object
Returns the value of attribute app.
-
#options ⇒ Object
Returns the value of attribute options.
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.
20 21 22 23 24 |
# File 'lib/ruby-metrics/integration/rack_middleware.rb', line 20 def initialize(app, ={}) @app = app @options = {:show => "/stats"}.merge() @agent = @options.delete(:agent) || Agent.new end |
Instance Attribute Details
#agent ⇒ Object
Returns the value of attribute agent.
18 19 20 |
# File 'lib/ruby-metrics/integration/rack_middleware.rb', line 18 def agent @agent end |
#app ⇒ Object
Returns the value of attribute app.
18 19 20 |
# File 'lib/ruby-metrics/integration/rack_middleware.rb', line 18 def app @app end |
#options ⇒ Object
Returns the value of attribute options.
18 19 20 |
# File 'lib/ruby-metrics/integration/rack_middleware.rb', line 18 def @options end |
Instance Method Details
#call(env) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/ruby-metrics/integration/rack_middleware.rb', line 26 def call(env) return show(env) if show?(env) env['metrics.agent'] = @agent status, headers, body = time_request { @app.call(env) } incr_status_code_counter(status / 100) [status, headers, body] rescue Exception # TODO: add "last_uncaught_exception" with string of error incr_uncaught_exceptions raise end |