Introduction to Java agent API

New Relic provides an API for controlling, customizing, or extending the functionality of the Java agent. The API consists of:

  • Static methods on the com.newrelic.api.agent.NewRelic class
  • A @Trace annotation for implementing custom instrumentation
  • A hierarchy of API objects providing additional functionality

For best results when using the API, ensure that you have the latest Java agent release. Several APIs used in the examples require Java agent 3.36.0 or higher.

Use the API

You can access the API class by adding newrelic-api.jar to your application class path. The jar is in the New Relic Java agent installation zip file.

See the Java agent API guide for a list of API functions broken down by practical goals.

API methods are documented in detail in the New Relic Javadoc. Some common API tasks include:

You can call the API when the Java agent is not running. The API methods are just stubs; the implementation is added when the Java agent loads the class.

API usage examples

For examples of the API in use, see:

For more help

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.