Java agent error configuration

New Relic APM's Java agent reports detailed information about errors that occur within your application. This gives you insight into problematic areas that may be affecting your application’s performance or the end user’s experience.

With Java agent versions 3.40.0 or higher, there are several configuration options that let you control how errors are reported, including:

Configuring expected errors so that they won't affect error rate or Apdex

Common reported error examples

If an unhandled error occurs within a transaction that the Java agent was tracing, the error will be reported with the full stack trace.

HTTP status codes (no stack trace)

If a transaction results in an HTTP status code, the error will be reported without the stack trace. This is because:

The application server detected an error condition and explicitly set the status code.

OR

The error condition was detected by program logic, and thus there was no exception object or stack.

In order to include the stack trace with these types of transactions, you must use a noticeError(...) API call.

noticeError(...) API calls

If the Java agent makes an explicit call using the noticeError(...) API call, the error will be reported regardless of whether or not it occurs within a transaction. The reported information depends on the parameters used in the noticeError(...) API call, as described in the Javadocs.

Unscoped errors reporting over 100%

The Java agent can report unscoped errors, which are errors that are not tied to any transaction. Because of this, it is possible to have one transaction in a timeslice and multiple errors in the same timeslice. In this situation, New Relic would then show an error rate over 100%.

In versions 3.40.0 or higher, you can control how errors are reported by using the YAML-based configuration. This allows you to ignore errors or expect errors based on HTTP status codes or based on a list of exception class names plus an optional error message.

Ignoring errors prevents the specified exception classes or codes from being reported to New Relic APM at all.

Expecting errors prevents the specified exception classes or codes from affecting your application's error rate and Apdex score. This allows you to retain the error information for troubleshooting purposes while avoiding alerts based on error rate or Apdex score.

These settings are dynamic, so running agents will notice changes to newrelic.yml without a JVM restart. For more information and examples, see the Java agent config file.

YAML-based configuration for error collection

YAML-based configuration for error collection allows you to entirely ignore specific errors or exempt expected errors from affecting your application’s error rate and Apdex score. You can mark errors as ignored or expected based on the following criteria:

A given range of HTTP status codes, presented as a comma-separated list or dashed range

A comma-separated list using the fully qualified name of a package/class and an optionally provided error message string

Enabling error collection

By default, the Java agent includes an error_collector stanza under which all YAML-based error configuration options will be found. Error collection can be enabled or disabled as follows:

error_collector:
enabled: true

Ignoring specific errors

Errors that are not of any particular interest can be ignored entirely. By identifying errors to ignore:

Errors that are expected as part of an application's business logic can be prevented from affecting error rate or Apdex score yet still be reported to APM. This allows you to retain the error information in the UI for troubleshooting purposes while avoiding alerts (based on error rate and Apdex score) caused by these errors.