Error Monitoring

Monitoring for your site just got easier. With our powerful error monitoring service backed by our class leading APM solution, get back to what really matters by easily consolidating your error service and APM solution into one. When the error monitoring service is enabled, you will gain access to the context in which errors occur on your application. With our high fidelity overview charts as well as our detailed error tracing, you will gain insights into your app’s error trends as well as how these issues arose.

error monitoring overview page

Enabling Error Monitoring

Error Monitoring is available to apps using Ruby 2.1+. To enable:

1. Within your Rails app’s directory, run:

bundle update scout_apm

Error Monitoring was released in scout_apm version 4.0.0.

2. Set the errors_enabled config option to true.

If you are using a config file:

# config/scout_apm.yml
production:
  errors_enabled: true

If you are using environment variables:

SCOUT_ERRORS_ENABLED=true

3. Deploy

4. Reach out to support@scoutapm.com to have us enable the service

Reporting Exceptions

Scout’s error middleware will automatically capture errors that reach it, and will record them and re-raise them.

There is no visible effect on your application, and the error will be propagated further up the middleware chain

However, if an error is rescued, the error will never reach our middleware. To report this error to Scout use:

ScoutApm::Error.capture(e)

Ex:

begin
    raise "Oh No!"
rescue => e
    ScoutApm::Error.capture(e)
end

Adding Context

Adding context to errors works exactly the same as adding context to web endpoints and background jobs.

If you have already added context to the endpoint or background job where the error has occurred, this context will be shown on the errors page.

Application Wide

To add context application wide context, you can add a before_action to the ApplicationController: (This will add the context to both errors as well as web endpoint traces)

class ApplicationController < ActionController::Base
  before_action :add_scout_context

  private

  def add_scout_context
    ## Adds user context of id
    ScoutApm::Context.add_user(id: current_user.id) if current_user
  end
end

When an error occurs, and if there is a user, the error will show which user the error occurred for

Individual Error

To add context to an individual error, such as one that is rescued:

begin
    raise "Oh No!"
rescue => e
    ScoutApm::Context.add(account: @account.id, other_values: "Can be a numeric, string, boolean, time, or date value") ## Add context to exception
    ScoutApm::Error.capture(e)
end

Visit our custom context section to learn more.

Error Notifications

Get notified of errors before your users notify you.

With our notification system, you can get error notifications sent to Slack, PagerDuty, Email, Webhooks, and more.

Slack Error Notification

Not seeing errors?

One thing to note is that by default we don’t collect errors for ActiveRecord::RecordNotFound as well as ActionController::RoutingError.

To collect these error types you will need to set errors_ignored_exceptions to an empty array: SCOUT_ERRORS_IGNORED_EXCEPTIONS=[]

Reach out to us at support@scoutapm.com for further support and troubleshooting assistance