Class: NewRelic::Rack::ErrorCollector
- Inherits:
-
Object
- Object
- NewRelic::Rack::ErrorCollector
- Defined in:
- lib/new_relic/rack/error_collector.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
- #ignored_in_controller?(exception, request) ⇒ Boolean
-
#initialize(app, options = {}) ⇒ ErrorCollector
constructor
A new instance of ErrorCollector.
- #newrelic_ignore_for_controller(controller_name) ⇒ Object
- #should_ignore_error?(error, request) ⇒ Boolean
Constructor Details
#initialize(app, options = {}) ⇒ ErrorCollector
Returns a new instance of ErrorCollector.
3 4 5 |
# File 'lib/new_relic/rack/error_collector.rb', line 3 def initialize(app, ={}) @app = app end |
Instance Method Details
#call(env) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/new_relic/rack/error_collector.rb', line 7 def call(env) @app.call(env) rescue Exception => exception request = Rack::Request.new(env) if !should_ignore_error?(exception, request) NewRelic::Agent.instance.error_collector.notice_error(exception, :uri => request.path, :referer => request.referer, :request_params => request.params) end raise exception end |
#ignored_in_controller?(exception, request) ⇒ Boolean
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/new_relic/rack/error_collector.rb', line 25 def ignored_in_controller?(exception, request) if request.env['action_dispatch.request.parameters'] ignore_actions = newrelic_ignore_for_controller(request.env['action_dispatch.request.parameters']['controller']) action_name = request.env['action_dispatch.request.parameters']['action'] case ignore_actions when nil; false when Hash only_actions = Array(ignore_actions[:only]) except_actions = Array(ignore_actions[:except]) only_actions.include?(action_name.to_sym) || (except_actions.any? && !except_actions.include?(action_name.to_sym)) else true end end end |
#newrelic_ignore_for_controller(controller_name) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/new_relic/rack/error_collector.rb', line 44 def newrelic_ignore_for_controller(controller_name) if controller_name controller_constant_name = (controller_name + "_controller").camelize if Object.const_defined?(controller_constant_name) controller = controller_constant_name.constantize controller.instance_variable_get(:@do_not_trace) end end rescue NameError nil end |