Sha256: a811d001decd1040ae1e36f78fb997b046c1881ca1abda7f34812b2f53f855b9

Contents?: true

Size: 922 Bytes

Versions: 5

Compression:

Stored size: 922 Bytes

Contents

require 'fozzie/rack/middleware'

module Fozzie
  module Rails

    # Time and record each request through a given Rails app
    # This middlewware times server processing for a resource, not view render.
    class Middleware < Fozzie::Rack::Middleware

      # Generates the statistics key for the current path
      def generate_key(env)
        path_str = env['PATH_INFO']
        return nil unless path_str

        begin
          routing = (rails_version == 3 ? ::Rails.application.routes : ::ActionController::Routing::Routes)
          path    = routing.recognize_path(path_str)
          stat    = [path[:controller], path[:action], "render"].join('.')
          stat
        rescue ActionController::RoutingError => exc
          S.increment "routing.error"
          nil
        rescue => exc
          nil
        end
      end

      def rails_version
        ::Rails.version.to_i
      end

    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
fozzie-0.0.20 lib/fozzie/rails/middleware.rb
fozzie-0.0.19 lib/fozzie/rails/middleware.rb
fozzie-0.0.18 lib/fozzie/rails/middleware.rb
fozzie-0.0.17 lib/fozzie/rails/middleware.rb
fozzie-0.0.16 lib/fozzie/rails/middleware.rb