Module: Oboe::Inst::RailsBase
- Included in:
- ActionController3, ActionController4
- Defined in:
- lib/oboe/frameworks/rails/inst/action_controller.rb
Overview
RailsBase
This module contains the instrumentation code common to many Rails versions.
Instance Method Summary collapse
-
#has_handler?(exception) ⇒ Boolean
has_handler?.
-
#log_rails_error?(exception) ⇒ Boolean
log_rails_error?.
-
#render_with_oboe(*args, &blk) ⇒ Object
render_with_oboe.
Instance Method Details
#has_handler?(exception) ⇒ Boolean
has_handler?
Determins if exception
has a registered handler via rescue_from
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/oboe/frameworks/rails/inst/action_controller.rb', line 19 def has_handler?(exception) # Don't log exceptions if they have a rescue handler set has_handler = false rescue_handlers.detect { | klass_name, handler | # Rescue handlers can be specified as strings or constant names klass = self.class.const_get(klass_name) rescue nil klass ||= klass_name.constantize rescue nil has_handler = exception.is_a?(klass) if klass } has_handler rescue => e Oboe.logger.debug "[oboe/debug] Error searching Rails handlers: #{e.}" return false end |
#log_rails_error?(exception) ⇒ Boolean
log_rails_error?
Determins whether we should log a raised exception to the TraceView dashboard. This is determined by whether the exception has a rescue handler setup and the value of Oboe::Config
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/oboe/frameworks/rails/inst/action_controller.rb', line 42 def log_rails_error?(exception) # As it's perculating up through the layers... make sure that # we only report it once. return false if exception.instance_variable_get(:@oboe_logged) has_handler = has_handler?(exception) if !has_handler || (has_handler && Oboe::Config[:report_rescued_errors]) return true end false end |
#render_with_oboe(*args, &blk) ⇒ Object
render_with_oboe
Our render wrapper that just times and conditionally reports raised exceptions
61 62 63 64 65 66 67 68 69 70 |
# File 'lib/oboe/frameworks/rails/inst/action_controller.rb', line 61 def render_with_oboe(*args, &blk) Oboe::API.log_entry('actionview') render_without_oboe(*args, &blk) rescue Exception => e Oboe::API.log_exception(nil, e) if log_rails_error?(e) raise ensure Oboe::API.log_exit('actionview') end |