Method: Datadog::Tracing::Contrib::ActionPack::Utils.exception_is_error?

Defined in:
lib/datadog/tracing/contrib/action_pack/utils.rb

.exception_is_error?(exception) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
14
15
16
17
18
19
20
21
# File 'lib/datadog/tracing/contrib/action_pack/utils.rb', line 11

def self.exception_is_error?(exception)
  if defined?(::ActionDispatch::ExceptionWrapper)
    # Gets the equivalent status code for the exception (not all are 5XX)
    # You can add custom errors via `config.action_dispatch.rescue_responses`
    status = ::ActionDispatch::ExceptionWrapper.status_code_for_exception(exception.class.name)
    # Only 5XX exceptions are actually errors (e.g. don't flag 404s)
    status.to_s.start_with?('5')
  else
    true
  end
end