New Relic .NET 代理如何工作?

How New Relic .NET agent works?

NewRelic .NET 代理的核心是如何工作的?它是以某种方式附加到 CLR 的某种 IIS 模块或 NewRelic 代理吗?

例如如果它通过 HttpClient 运行,它如何知道某些请求是外部请求?

所有监控 .NET 的 APM 工具(领导者是 AppDynamics、New Relic 和 Dynatrace)基本上做同样的事情。为了从 CLR 收集数据,他们使用分析 API https://msdn.microsoft.com/en-us/library/bb384493(v=vs.110).aspx but the trick is doing this while minimizing overhead. You must instrument in a smart way, to avoid causing performance issues. The more advanced products will also do code injection (we do this at AppDynamics for example) here is a sample app for adding your own code in at runtime. https://www.codeproject.com/Articles/463508/NET-CLR-Injection-Modify-IL-Code-during-Run-time

他们还将此与通过 OS、.NET 运行时、IIS 等的 WMI 收集数据相结合。

您可以看到 APM 工具非常复杂,在生产中以低开销大规模执行此操作是一项挑战。哦,是的,记住你也不能破坏任何东西。这就是构建一个好的 APM 产品需要数年时间的原因。如果您在 API 中有具体问题,我至少可以在 AppDynamics 上解释更多:)