module Oboe::Inst::RailsBase

RailsBase

This module contains the instrumentation code common to many Rails versions.

Public Instance Methods

has_handler?(exception) click to toggle source

has_handler?

Determins if exception has a registered handler via rescue_from

# 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.message}"
  return false
end
log_rails_error?(exception) click to toggle source

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

# 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) click to toggle source

render_with_oboe

Our render wrapper that just times and conditionally reports raised exceptions

# 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