how does NewRelic work by simply installing .Net agent?

New Relic says themselves that they use the .Net profiling API.

https://docs.newrelic.com/docs/dotnet/new-relic-net-installation#trouble

The .NET agent instruments application and system code using BCI (byte code injection). This is done by registering the New Relic agent with the CLR (Common Language Runtime) as a "profiler." The CLR calls out to the .NET agent when code is loaded, and the agent instruments the code if it's an interesting method call.


The key difference between the New Relic .NET Agent and traditional profiling tools is that the New Relic .NET Agent doesn't instrument everything. Developers at New Relic have gone through and picked out key methods in various frameworks (e.g., ASP.NET) and libraries (e.g., SQL Server) and the agent injects code into those methods only. A traditional profiler will inject code into everything which is why they generally slow your application down. By selectively injecting code, New Relic can be sure to keep overhead low yet still give you insight into the interesting parts of your application.