Sha256: 5ae0edc2b9fec3d22e3d616cc0e5e17eaff961c0862d58af948642dfd2ac47cd

Contents?: true

Size: 1.2 KB

Versions: 19

Compression:

Stored size: 1.2 KB

Contents

require 'benchmark'

module Errplane
  module Rails
    module Benchmarking
      def self.included(base)
        base.send(:alias_method_chain, :perform_action, :instrumentation)
        base.send(:alias_method_chain, :view_runtime, :instrumentation)
        base.send(:alias_method_chain, :active_record_runtime, :instrumentation)
      end

      private
      def perform_action_with_instrumentation
        ms = Benchmark.ms { perform_action_without_instrumentation }
        if Errplane.configuration.instrumentation_enabled
          Errplane.report "controllers/#{params[:controller]}/#{params[:action]}", :value => ms.ceil
        end
      end

      def view_runtime_with_instrumentation
        runtime = view_runtime_without_instrumentation
        if Errplane.configuration.instrumentation_enabled
          Errplane.report "views", :value => runtime.split.last.to_f.ceil
        end
        runtime
      end

      def active_record_runtime_with_instrumentation
        runtime = active_record_runtime_without_instrumentation
        if Errplane.configuration.instrumentation_enabled
          Errplane.report "db", :value => runtime.split.last.to_f.ceil
        end
        runtime
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
errplane-1.0.0 lib/errplane/rails/benchmarking.rb
errplane-0.6.10 lib/errplane/rails/benchmarking.rb
errplane-0.6.9 lib/errplane/rails/benchmarking.rb
errplane-0.6.8 lib/errplane/rails/benchmarking.rb
errplane-0.6.7 lib/errplane/rails/benchmarking.rb
errplane-0.6.6 lib/errplane/rails/benchmarking.rb
errplane-0.6.5 lib/errplane/rails/benchmarking.rb
errplane-0.6.4 lib/errplane/rails/benchmarking.rb
errplane-0.6.3 lib/errplane/rails/benchmarking.rb
errplane-0.6.2 lib/errplane/rails/benchmarking.rb
errplane-0.6.1 lib/errplane/rails/benchmarking.rb
errplane-0.6.0 lib/errplane/rails/benchmarking.rb
errplane-0.5.30 lib/errplane/rails/benchmarking.rb
errplane-0.5.29 lib/errplane/rails/benchmarking.rb
errplane-0.5.28 lib/errplane/rails/benchmarking.rb
errplane-0.5.27 lib/errplane/rails/benchmarking.rb
errplane-0.5.26 lib/errplane/rails/benchmarking.rb
errplane-0.5.25 lib/errplane/rails/benchmarking.rb
errplane-0.5.24 lib/errplane/rails/benchmarking.rb