Sha256: 97a08923af6bcb011f0a066abe1ff5c377026dd7c376ab834c8acae003f28545

Contents?: true

Size: 915 Bytes

Versions: 2

Compression:

Stored size: 915 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 = routing_lookup
          path    = routing.recognize_path(path_str)
          stat    = [path[:controller], path[:action], "render"].join('.')
          stat
        rescue => exc
          S.increment "routing.error"
          nil
        end
      end

      def routing_lookup
        (rails_version == 3 ? ::Rails.application.routes : ::ActionController::Routing::Routes)
      end

      def rails_version
        ::Rails.version.to_i
      end

    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fozzie-0.0.22 lib/fozzie/rails/middleware.rb
fozzie-0.0.21 lib/fozzie/rails/middleware.rb