Custom instrumentation allows you to expand the agent's default monitoring and behavior to target additional functional calls and activity. You can do so via the agent config file, or via the agent API.
There are two main methods for adding custom instrumentation:
- If you simply want to trace time spent in additional functions or methods of classes, you can identify a list of functions or methods in the agent configuration file. For more information, see Instrumentation via config file.
- For more complex cases, or if you want to customize how the function is identified in the New Relic One UI, you can place API calls in your application code. For more information, see Instrumentation via API.
In either case, these mechanisms only target the designated function call. It is not recursive, nor does it enable full profiling below the annotated function.
You must individually annotate each function call you want to trace. If you are not sure which function you should annotate, you can use thread profiling features to narrow it down.
Collecting too many metrics can impact the performance of both your application and the agent. To avoid potential data problems, try to keep the total number of unique metrics introduced by custom instrumentation under 2000.