class SystemMetrics::Middleware

Public Class Methods

new(app, collector, path_exclude_patterns) click to toggle source
# 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

Public Instance Methods

call(env) click to toggle source
# 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

Protected Instance Methods

exclude_path?(path) click to toggle source
# File lib/system_metrics/middleware.rb, line 24
def exclude_path?(path)
  @path_exclude_patterns.any? { |pattern| pattern =~ path }
end
notifications() click to toggle source
# File lib/system_metrics/middleware.rb, line 28
def notifications
  ActiveSupport::Notifications
end