Ignoring specific transactions

New Relic for Ruby allows you to selectively disable instrumentation for particular requests within your Rails or Sinatra application.

Blocking all instrumentation

Call newrelic_ignore with no arguments from within a Rails controller or Sinatra application to prevent instrumentation of all requests serviced by that controller or application:


Using newrelic_ignore prevents the agent from recording any performance data (metrics, transaction traces, Insights events, traced errors, and so on) for the targeted transactions, and will also prevent the transactions from contributing to your overall Apdex score.

Ignoring specific actions with Rails

If you want to ignore only specific actions with a Rails controller, you can use the :only or :except options with newrelic_ignore.

For example, to ignore only the index and show actions on the controller, use:

newrelic_ignore :only => [:index, :show]

To ignore all actions on the controller except index:

newrelic_ignore :except => [:index]

Ignoring specific routes with Sinatra

If you want to ignore only specific routes within your Sinatra application, you can pass a Sinatra-style route definition to newrelic_ignore from within your Sinatra application. For more information, see Sinatra: Ignoring routes.

Ignoring Apdex contributions

If you want to prevent all actions in a controller from contributing to your Apdex score, but still want other performance data, use newrelic_ignore_apdex:


In a Rails application, newrelic_ignore_apdex supports the same :only and :except options as newrelic_ignore. In a Sinatra application, it will accept the same Sinatra-style route for targeting specific transactions.

Blocking Browser instrumentation

Using newrelic_ignore_enduser prevents the agent from automatically inserting the JavaScript used to capture New Relic Browser data. Server-side instrumentation will be unaffected.

To prevent Browser agent injection for all actions in a controller, add a call like this to the controller class:


In a Rails application, newrelic_ignore_enduser supports the same :only and :except options as newrelic_ignore. In a Sinatra application, it will accept the same Sinatra-style route for targeting specific transactions.

Ignoring transactions dynamically

In some cases, you may want to base the decision to ignore a specific transaction on criteria only known at runtime, during the request. For scenarios like this, the declarative mechanisms explained above aren't a good fit. Starting in Ruby agent version 3.9.2, you can instead use the following family of API calls from any point within your transaction:


These methods will have a similar results to the newrelic_ignore, newrelic_ignore_apdex, and newrelic_ignore_enduser calls, but can be called during a request instead of during the class definition.

Ignoring transactions by URL with configuration

You can ignore transactions by URL using the rules.ignore_url_regexes configuration setting:

  ignore_url_regexes: ["secret", "^/admin"]

Note that regexes do not include any type of anchoring by default. The /secret/ regex will match 'newrelic.com/secret/login' and it will also match 'newrelic.com/users/secretpanda'. The anchored admin regex will match 'newrelic.com/admin/praetorians' but it will not match 'newrelic.com/users/totally-real-admin'.

If necessary you may also provide a list of regexes in a comma-separated string, allowing you to set ignore regexes with an environment variable:


As always configuration from environment variables will override configuration in newrelic.yml.


The newrelic_ignore* family of methods will only work from within Rails controller classes, or Sinatra applications (subclasses of Sinatra::Base). Other applications should use the NewRelic::Agent.ignore_* family of calls from within each request that you would like to ignore, which will work in any context.

If you get a NoMethodError when trying to use newrelic_ignore from within a Rails controller or Sinatra application, make sure that newrelic_rpm has been required before you try to call newrelic_ignore inside of your class definition.

For more help

Additional documentation resources include Apdex: Measuring user satisfaction (how Apdex is calculated).

Join the discussion about Ruby in the New Relic Online Technical Community! The Technical Community is a public platform to discuss and troubleshoot your New Relic toolset.

If you need additional help, get support at support.newrelic.com.