Ignore specific transactions using API

New Relic for Java gives you multiple methods to ignore specific transactions. This document explains how to use the Java agent API to block instrumentation.

It is also possible to use the API and XML instrumentation to ignore transactions. For information on custom instrumentation methods and when to use them, see Custom instrumentation.

Ignore transactions with ServletRequest

To ignore a web transaction, set a ServletRequest attribute named com.newrelic.agent.IGNORE to true during the request:

request.setAttribute("com.newrelic.agent.IGNORE", true);

To specify URLs to ignore, create a servlet filter which sets that attribute and apply the filter to the servlet you want to ignore. The filter will have access to the request URI if you need to ignore specific URLs.

Ignore transactions with annotation

To tell the Java agent to ignore transactions using annotations:

  1. Define an annotation called NewRelicIgnoreTransaction:

    public @interface NewRelicIgnoreTransaction {
  2. Apply the annotation to the methods or classes you want to ignore. For example:

    public void ignore() {

If a transaction calls a method or class annotated with @NewRelicIgnoreTransaction, the transaction is ignored. This means it does not contribute to the overall Apdex score; and the transaction trace and performance data is not reported.

Ignore apdex but not traces

You can also prevent the transaction from contributing to the Apdex score but still be used in transaction traces. Define a NewRelicIgnoreApdex annotation:

public @interface NewRelicIgnoreApdex {

For more help

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

Join the discussion about Java monitoring 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.