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.
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
If you are using a config file:
# config/scout_apm.yml production: errors_enabled: true
If you are using environment variables:
4. Reach out to firstname.lastname@example.org to have us enable the service
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:
begin raise "Oh No!" rescue => e ScoutApm::Error.capture(e) end
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.
To add context application wide context, you can add a
before_action to the
(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
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.
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.
Not seeing errors?
One thing to note is that by default we don’t collect errors for
ActiveRecord::RecordNotFound as well as
To collect these error types you will need to set
errors_ignored_exceptions to an empty array: