Error Monitoring

Note: For general error monitoring feature documentation, see the Error Monitoring features page.

Scout’s Error Monitoring feature allows you to track, triage, and resolve Elixir application errors directly within the Scout UI. By integrating with our existing APM agent, we provide enhanced context and filtering capabilities for comprehensive error management.

Installation

AIf you haven't already, set up Scout APM for Elixir.

BAttach the Phoenix error telemetry handler in your Application.start/2:

def start(_type, _args) do
  ScoutApm.Instruments.PhoenixErrorTelemetry.attach()
  # ...
end

CDeploy!

Error monitoring is enabled by default (errors_enabled: true). Once the telemetry handler is attached, Scout will automatically begin capturing and organizing errors from your application.

Configuration Options

The following configuration settings are available for error monitoring. These can be set in your config/scout_apm.exs file or as environment variables with the SCOUT_ prefix, e.g. SCOUT_ERRORS_ENABLED.

Only errors_enabled is required to enable error monitoring. The rest are optional.

Setting Name Description Default Required
errors_enabled Enable or disable error capture. true No
errors_host The endpoint where errors are reported. https://errors.scoutapm.com No
errors_batch_size Number of errors sent per batch. 5 No
errors_max_queue_size Maximum number of errors queued before dropping. 500 No
errors_flush_interval_ms How often (in milliseconds) the error queue is flushed. 1000 No
errors_ignored_exceptions A list of exception modules to ignore (e.g., [Phoenix.Router.NoRouteError]). [] No
errors_filter_parameters A list of parameter keys to redact from error reports (e.g., ["password", "credit_card"]). [] No

Example configuration:

config :scout_apm,
  errors_enabled: true,
  errors_ignored_exceptions: [Phoenix.Router.NoRouteError],
  errors_filter_parameters: ["password", "credit_card"]

Custom Error Reporting

In addition to automatically capturing unhandled exceptions, Scout provides an API for manually reporting errors with custom context.

Basic Usage

try do
  some_risky_operation()
rescue
  e ->
    ScoutApm.Error.capture(e, stacktrace: __STACKTRACE__)
    reraise e, __STACKTRACE__
end

With Additional Context

ScoutApm.Error.capture(e,
  stacktrace: __STACKTRACE__,
  context: %{user_id: user.id},
  request_path: "/api/users",
  request_params: %{action: "update"}
)

Error Context and Attributes

Scout automatically enriches error data with contextual information:

This context makes it easy to understand the circumstances that led to each error occurrence.

Data Retention

Scout retains error data for 30 days, and aggregate parent groups (total counts, first seen at (& sha), last error message, etc) indefinitely, providing sufficient time for analysis and resolution tracking. This retention period allows teams to:

Integration with APM

Error monitoring seamlessly integrates with Scout’s APM features:

For more detailed information on error management features, triage workflows, and team collaboration tools, see the main Error Monitoring documentation.

How It Works

Error monitoring is built into the Scout APM Elixir agent. When an error occurs in your Phoenix application, Scout automatically captures:

For Phoenix applications, Scout integrates via :telemetry to capture both handled and unhandled exceptions.

Not seeing errors?

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