---
title: Ruby agent error collector settings
source: https://docs.newrelic.com/docs/apm/agents/ruby-agent/configuration/ruby-agent-configuration-error-collector-settings
---

Configure the Ruby agent's error collector to customize how errors are captured, which errors to ignore or treat as expected, and how error events are sampled.

## Error Collector [#error-collector]

The agent collects and reports all uncaught exceptions by default. These configuration options allow you to customize the error collection.

For information on ignored and expected errors, [see this page on Error Analytics in APM](https://docs.newrelic.com/docs/agents/manage-apm-agents/agent-data/manage-errors-apm-collect-ignore-or-mark-expected/). To set expected errors via the `NewRelic::Agent.notice_error` Ruby method, [consult the Ruby agent API](https://docs.newrelic.com/docs/agents/ruby-agent/api-guides/sending-handled-errors-new-relic/).

**error_collector.capture_events**

| TypeBoolean                                              |
| -------------------------------------------------------- |
| Defaulttrue                                              |
| Environ variableNEW_RELIC_ERROR_COLLECTOR_CAPTURE_EVENTS |

If `true`, the agent collects [`TransactionError` events](https://docs.newrelic.com/docs/insights/new-relic-insights/decorating-events/error-event-default-attributes-insights).

**error_collector.enabled**

| TypeBoolean                                       |
| ------------------------------------------------- |
| Defaulttrue                                       |
| Environ variableNEW_RELIC_ERROR_COLLECTOR_ENABLED |

If `true`, the agent captures traced errors and error count metrics.

**error_collector.expected_classes**

| TypeArray            |
| -------------------- |
| Default\[]           |
| Environ variableNone |

A list of error classes that the agent should treat as expected.
This option can't be set via environment variable.

**error_collector.expected_messages**

| TypeHash             |
| -------------------- |
| Default{}            |
| Environ variableNone |

A map of error classes to a list of messages. When an error of one of the classes specified here occurs, if its error message contains one of the strings corresponding to it here, that error will be treated as expected.
This option can't be set via environment variable.

**error_collector.expected_status_codes**

| TypeString                                                      |
| --------------------------------------------------------------- |
| Default""                                                       |
| Environ variableNEW_RELIC_ERROR_COLLECTOR_EXPECTED_STATUS_CODES |

A comma-separated list of HTTP status codes and/or status code ranges (for example, `404, 429, 500-599`). Errors associated with a matching status code, if the error has one, will be treated as expected.

**error_collector.ignore_classes**

| TypeArray                                                       |
| --------------------------------------------------------------- |
| Default\["ActionController::RoutingError", "Sinatra::NotFound"] |
| Environ variableNone                                            |

A list of error classes that the agent should ignore.
This option can't be set via environment variable.

**error_collector.ignore_messages**

| TypeHash                               |
| -------------------------------------- |
| Default{ThreadError: \["queue empty"]} |
| Environ variableNone                   |

A map of error classes to a list of messages. When an error of one of the classes specified here occurs, if its error message contains one of the strings corresponding to it here, that error will be ignored.
This option can't be set via environment variable.

**error_collector.ignore_status_codes**

| TypeString                                                    |
| ------------------------------------------------------------- |
| Default""                                                     |
| Environ variableNEW_RELIC_ERROR_COLLECTOR_IGNORE_STATUS_CODES |

A comma-separated list of HTTP status codes and/or status code ranges (for example, `404, 429, 500-599`). Errors associated with a matching status code, if the error has one, will be ignored.

**error_collector.max_backtrace_frames**

| TypeInteger                                                    |
| -------------------------------------------------------------- |
| Default50                                                      |
| Environ variableNEW_RELIC_ERROR_COLLECTOR_MAX_BACKTRACE_FRAMES |

Defines the maximum number of frames in an error backtrace. Backtraces over this amount are truncated in the middle by default, preserving the beginning and the end of the stack trace. See [`error_collector.backtrace_truncate_location`](#error_collector-backtrace_truncate_location) to customize the truncation location.

**error_collector.backtrace_truncate_location**

| TypeString                                                            |
| --------------------------------------------------------------------- |
| Default"middle"                                                       |
| Environ variableNEW_RELIC_ERROR_COLLECTOR_BACKTRACE_TRUNCATE_LOCATION |

Specifies where in the backtrace to truncate when the number of frames exceeds [`error_collector.max_backtrace_frames`](#error_collector-max_backtrace_frames). Options are `top` (remove frames from the beginning), `middle` (remove frames from the middle, preserving the beginning and end), or `end` (remove frames from the end).

**error_collector.max_event_samples_stored**

| TypeInteger                                                        |
| ------------------------------------------------------------------ |
| Default100                                                         |
| Environ variableNEW_RELIC_ERROR_COLLECTOR_MAX_EVENT_SAMPLES_STORED |

Defines the maximum number of [`TransactionError` events](https://docs.newrelic.com/docs/insights/new-relic-insights/decorating-events/error-event-default-attributes-insights) reported per harvest cycle.

## Errors inbox configuration [#errors-inbox-configuration]

Setting one of the following environment variables will help you identify which versions of your software produced the errors.

-   `NEW_RELIC_METADATA_SERVICE_VERSION` creates `tags.service.version` on event data containing the version of your code that is deployed, in many cases a semantic version such as `1.2.3`, but not always.
-   `NEW_RELIC_METADATA_RELEASE_TAG` creates `tags.releaseTag` on event data containing the release tag (such as `v0.1.209` or `release-209`).
-   `NEW_RELIC_METADATA_COMMIT` creates `tags.commit` on event data containing the commit SHA. The entire SHA can be used or just the first seven characters (e.g., `734713b`).

[Errors inbox](https://docs.newrelic.com/docs/errors-inbox/version-tracking/) will automatically track which versions of your software are producing errors.
