Sending New Relic handled errors

To send error data that you are handling in your own code to New Relic, use the Ruby agent API NewRelic::Agent.notice_error call within your error handler.

Notify the New Relic Ruby agent of an error

This API call takes the exception and an optional options hash. Use this format:

notice_error(exception, options = { }) ⇒ Object

This function records the given error and passes it through the normal error filtering process, including configuration-based ignoring of errors and the global #ignore_error_filter method if defined.

The exception is the exception to be recorded, or an error message. If needed, you can also include options = { }. The following parameters will receive special treatment, and any other parameters you supply will be treated as custom parameters.

options = { } Comments
:expected

Only records the error trace. This does not affect the error rate or Apdex status.

Replaces the :trace_only option, which was deprecated in version 4.3.x of the Ruby agent.

:custom_params

Custom parameters.

:uri

The request path, minus any request parameters or query string.

Usually not needed. Include this only if you are calling notice_error outside a transaction.

:metric

The metric name associated with the transaction.

Usually not needed. Include this only if you are calling notice_error outside a transaction.

:request_params (deprecated) Older Ruby agent versions allowed passing a :request_params option, but those are now ignored. If you need to record the request parameters, call this method inside a transaction, or pass the information in :custom_params.

For more help

Additional documentation resources include:

Recommendations for learning more: