Sha256: d0a95803e1637d2d8d1d1e005557bad45248ec1cf7cbf4be65acde3506105d70

Contents?: true

Size: 1.46 KB

Versions: 33

Compression:

Stored size: 1.46 KB

Contents

# encoding: utf-8
# This file is distributed under New Relic's license terms.
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.

DependencyDetection.defer do
  @name = :rails2_error

  depends_on do
    defined?(ActionController) && defined?(ActionController::Base)
  end

  depends_on do
    defined?(::Rails) && ::Rails::VERSION::MAJOR.to_i == 2
  end

  executes do
    ::NewRelic::Agent.logger.info 'Installing Rails 2 Error instrumentation'
  end

  executes do

    ActionController::Base.class_eval do

      # Make a note of an exception associated with the currently executing
      # controller action.  Note that this used to be available on Object
      # but we replaced that global method with NewRelic::Agent#notice_error.
      # Use that one outside of controller actions.
      def newrelic_notice_error(exception, custom_params = {})
        NewRelic::Agent::Transaction.notice_error exception, :custom_params => custom_params, :request => request
      end

      def rescue_action_with_newrelic_trace(exception)
        rescue_action_without_newrelic_trace exception
        NewRelic::Agent::Transaction.notice_error exception, :request => request
      end

      # Compare with #alias_method_chain, which is not available in
      # Rails 1.1:
      alias_method :rescue_action_without_newrelic_trace, :rescue_action
      alias_method :rescue_action, :rescue_action_with_newrelic_trace
      protected :rescue_action

    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
newrelic_rpm-3.11.2.286 lib/new_relic/agent/instrumentation/rails/errors.rb
newrelic_rpm-3.11.1.284 lib/new_relic/agent/instrumentation/rails/errors.rb
newrelic_rpm-3.11.0.283 lib/new_relic/agent/instrumentation/rails/errors.rb
newrelic_rpm-3.10.0.279 lib/new_relic/agent/instrumentation/rails/errors.rb
newrelic_rpm-3.9.9.275 lib/new_relic/agent/instrumentation/rails/errors.rb
newrelic_rpm-3.9.8.273 lib/new_relic/agent/instrumentation/rails/errors.rb
newrelic_rpm-3.9.7.266 lib/new_relic/agent/instrumentation/rails/errors.rb
newrelic_rpm-3.9.6.257 lib/new_relic/agent/instrumentation/rails/errors.rb
newrelic_rpm-3.9.5.251 lib/new_relic/agent/instrumentation/rails/errors.rb
newrelic_rpm-3.9.4.245 lib/new_relic/agent/instrumentation/rails/errors.rb
newrelic_rpm-3.9.3.241 lib/new_relic/agent/instrumentation/rails/errors.rb
newrelic_rpm-3.9.2.239 lib/new_relic/agent/instrumentation/rails/errors.rb
newrelic_rpm-3.9.1.236 lib/new_relic/agent/instrumentation/rails/errors.rb
newrelic_rpm-3.9.0.229 lib/new_relic/agent/instrumentation/rails/errors.rb
newrelic_rpm-3.8.1.221 lib/new_relic/agent/instrumentation/rails/errors.rb
newrelic_rpm-3.8.0.218 lib/new_relic/agent/instrumentation/rails/errors.rb
newrelic_rpm-3.7.3.204 lib/new_relic/agent/instrumentation/rails/errors.rb
newrelic_rpm-3.7.3.199 lib/new_relic/agent/instrumentation/rails/errors.rb
newrelic_rpm-3.7.2.195 lib/new_relic/agent/instrumentation/rails/errors.rb
newrelic_rpm-3.7.2.192 lib/new_relic/agent/instrumentation/rails/errors.rb