New Relic provides an API for controlling, customizing, or extending the functionality of the Java agent. The API consists of:
- Static methods on the
- 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:
- Custom instrumentation by annotation
- Custom framework instrumentation API
- Prevent unwanted instrumentation
- Insert custom attributes (Java)
- Insert custom events (Java)
- Collect custom metrics
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:
- Instrumenting an example app with annotations
- Overview of using API to record external calls, cross application tracing (CAT), messaging, datastore, and web frameworks
- Example of using API to instrument CAT and external datastore calls