Error Monitoring
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:
- Entrypoint: The top-level action (e.g. Controller module) where the error occurred
- Custom Context: All key-value pairs from any Custom Context that you have set
- Request Data: HTTP method, URI, parameters, and headers
- User Context: User identification and session information (when configured)
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:
- Identify recurring error patterns
- Analyze error trends over time
- Maintain historical context for resolved issues
- Support post-incident analysis and learning
Integration with APM
Error monitoring seamlessly integrates with Scout’s APM features:
- Performance Context: View error occurrences alongside performance traces
- Endpoint Analysis: Identify which endpoints generate the most errors
- Critical Endpoint Errors: Automatically prioritize errors from marked critical endpoints
- Time Correlation: Correlate errors with performance degradation events
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:
- Complete stack trace showing the execution path leading to the error
- Request information including URI, method, and parameters
- Application context including custom context data
- Error grouping based on error type and location
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