Class: UnicornMetrics::Middleware
- Inherits:
-
Raindrops::Middleware
- Object
- Raindrops::Middleware
- UnicornMetrics::Middleware
- Defined in:
- lib/unicorn_metrics/middleware.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, opts = {}) ⇒ Middleware
constructor
A new instance of Middleware.
Constructor Details
#initialize(app, opts = {}) ⇒ Middleware
Returns a new instance of Middleware.
11 12 13 14 15 |
# File 'lib/unicorn_metrics/middleware.rb', line 11 def initialize(app, opts = {}) @registry = UnicornMetrics::Registry @metrics_path = opts[:metrics] || "/metrics" super end |
Instance Method Details
#call(env) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/unicorn_metrics/middleware.rb', line 17 def call(env) return metrics_response if env['PATH_INFO'] == @metrics_path response = nil time = Benchmark.realtime do response = super #=> [ status, headers, <#Raindrops::Middleware::Proxy> ] # Proxy is a wrapper around the response body end collect_http_metrics(env, response, time) if UnicornMetrics.http_metrics? response end |