Class: SystemMetrics::Middleware

Inherits:
Object
  • Object
show all
Defined in:
lib/system_metrics/middleware.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, collector, path_exclude_patterns) ⇒ Middleware

Returns a new instance of Middleware.



3
4
5
6
7
# File 'lib/system_metrics/middleware.rb', line 3

def initialize(app, collector, path_exclude_patterns)
  @app = app
  @collector = collector
  @path_exclude_patterns = path_exclude_patterns
end

Instance Method Details

#call(env) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/system_metrics/middleware.rb', line 9

def call(env)
  if exclude_path? env["PATH_INFO"]
    @app.call(env)
  else
    @collector.collect do
      response = notifications.instrument "request.rack",
        :path => env["PATH_INFO"], :method => env["REQUEST_METHOD"] do
        @app.call(env)
      end
    end
  end
end