为什么Application Insights Performance Counter Collection会导致高CPU使用率

时间:2017-05-25 09:39:30

标签: monitoring azure-application-insights

我们的性能团队执行的日志记录表明,这条线路正在扼杀我们的CPU

Microsoft.AI.PerfCounterCollector!Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector.Implementation.PerformanceCounterUtility.ExpandInstanceName()

一种理论是用于识别库中Perf计数器的正则表达式是递归的

https://adtmag.com/blogs/dev-watch/2016/07/stack-overflow-crash.aspx

我已经检查了Perf Counter的名字,没有什么看起来特别不合适的名字和正则表达应该没有麻烦咀嚼它们。当然,在很长一段时间内都没有任何问题。

我现在已启用Applications Insights Diagnostic Logging以尝试观察此问题(在测试环境中)

有没有其他人观察到这一点,我们如何减轻这种情况呢? 我们确保DeveloperMode未设置为开启。

2 个答案:

答案 0 :(得分:1)

您收集的计数器是否在其名称中使用了实例占位符?如果实例名称在构建时已知,则删除占位符可以显着提高性能。例如,而不是

\Process(??APP_WIN32_PROC??)\% Processor Time

尝试使用

\Process(w3wp)\% Processor Time

另外,你整体收集了多少个计数器?

答案 1 :(得分:1)

这个答案很可能现在不可用,因为AppInsights 2代码得到了很大改进,但在我的情况下,它是双重调用AddApplicationInsightsTelemetry()。每次调用此方法时都会添加收集器,并且由于perf计数器收集器代码内部缺乏同步,因此会产生CPU峰值。

因此,请避免多次调用AddApplicationInsightsTelemetry,或使用AppInsights 2.x. (最好的办法是两者兼顾)。

相关问题