Class: Fozzie::Rails::Middleware
- Inherits:
-
Fozzie::Rack::Middleware
- Object
- Fozzie::Rack::Middleware
- Fozzie::Rails::Middleware
- Defined in:
- lib/fozzie/rails/middleware.rb
Overview
Time and record each request through a given Rails app This middlewware times server processing for a resource, not view render.
Instance Method Summary collapse
-
#generate_key(env) ⇒ Object
Generates the statistics key for the current path.
- #rails_version ⇒ Object
- #routing_lookup ⇒ Object
Instance Method Details
#generate_key(env) ⇒ Object
Generates the statistics key for the current path
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/fozzie/rails/middleware.rb', line 11 def generate_key(env) path_str, request_method = env['PATH_INFO'], env['REQUEST_METHOD'] return nil unless path_str begin routing = routing_lookup path = routing.recognize_path(path_str, :method => request_method) stat = [path[:controller], path[:action], "render"].join('.') stat rescue => exc S.increment "routing.error" nil end end |
#rails_version ⇒ Object
31 32 33 |
# File 'lib/fozzie/rails/middleware.rb', line 31 def rails_version ::Rails.version.to_i end |
#routing_lookup ⇒ Object
27 28 29 |
# File 'lib/fozzie/rails/middleware.rb', line 27 def routing_lookup (rails_version >= 3 ? ::Rails.application.routes : ::ActionController::Routing::Routes) end |