Relic Solution: .NET Agent “Instrumentation” Explained

When reading about the .NET agent and how you can use it to monitor your applications, you’ll likely run across many references to “instrumentation”, especially if you’re trying to monitor a service app (as opposed to a web application).

Instrumentation in the .NET agent refers to some type of configuration that tells the agent to take action when a particular method is called in your code. That action might be creating a transaction, adding detail to an existing transaction, ignoring a transaction, renaming a transaction, etc.

Though this explanation is over-simplified, how it works is basically this: When an application starts up on your system and the New Relic .NET agent’s profiler is loaded into the application’s process, the .NET CLR/Runtime passes each method signature called in your application to the New Relic .NET agent and “asks” if the agent wants to do something with it. The agent then checks to see if it has instrumentation that matches that method signature and, if so, applies it. If the agent does not have instrumentation that matches that signature, it does nothing.

The default instrumentation provided with the .NET agent is contained in a set of XML files located in the “extensions” folder that came with the agent (in Windows installations, the default location is C:\ProgramData\New Relic\.NET Agent\extensions).

You can also create your own instrumentation if you need to monitor parts of your code which are not instrumented by default. This is known as “custom instrumentation”. When you create custom instrumentation, you can either use XML files (like the agent’s default instrumentation does) or you can use in-code annotations to mark the methods you want to instrument.

Official documentation on creating custom instrumentation can be found at this link