c# - 桌面应用程序中的 Application Insights 不会发送性能计数器

标签 c# azure azure-application-insights

我正在关注these instructions 将 App Insights 添加到 Windows 桌面应用。我在代码中添加了一些 TrackMetric 和 TrackException 调用,并且这些数据在门户中显示得很好,所以我知道基本管道正在工作。

基于these instructions ,然后我将 AI.Web NuGet 包添加到我的项目中(是的,我知道这听起来很奇怪,但特别推荐)并禁用配置文件中的所有除了以下模块/初始化程序:

  • 诊断遥测模块
  • DependencyTrackingTelemetryModule
  • 性能收集器模块
  • DeviceTelemetryInitializer

附加设备信息开始显示在我的遥测数据中,因此我知道应用程序至少正在获取配置文件设置。

不幸的是,无论我做什么,都没有显示任何标准性能计数器指标。

我还需要做些什么才能在桌面应用程序中启用性能计数器收集吗?

预先感谢您提供的任何、呃、见解...:)

编辑:“标准性能计数器”是指默认情况下跟踪的 ​​Windows 性能计数器 PerformanceCollectorModule,根据 instructions之前链接,其中指出:

PerformanceCollectorModule tracks a number of Windows performance counters. You can see these counters when you click a chart in Metric Explorer to open its details blade.

You can monitor additional performance counters - both standard Windows counters and any others that you have added...

很明显,我不必将标准计数器添加到配置文件中——只需添加我想要包含的任何其他计数器即可。

最佳答案

理想情况下,您应该能够仅使用 Perf Counter Collector nuget package在您的应用的基本 Application Insights 包之上。

您仍然需要在 appinsights.config 文件中或通过代码设置要监视的性能计数器,这在 instructions you linked 中进行了记录。到,例如:

<Add Type="Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector.PerformanceCollectorModule, Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector">
  <Counters>
    <Add PerformanceCounter="\MyCategory\MyCounter" />
    <Add PerformanceCounter="\Process(??APP_WIN32_PROC??)\Handle Count" ReportAs="Process handle count" />
    <!-- ... -->
  </Counters>
</Add>

我相信 Web SDK 只是设置了一堆 ASP.NET 管道/w3wp 性能计数器,这在标准 Windows 应用程序中不会执行任何操作。

关于c# - 桌面应用程序中的 Application Insights 不会发送性能计数器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32418946/

相关文章:

c# - 如何在一个 VS 解决方案中运行 NUnit 测试之前启动控制台应用程序?

c# - UserPrincipal.FindByIdentity 导致 COM 错误 0x80005000

c# - 如何在 Windows Azure 上为 Windows Phone 使用 Microsoft Translator API?

reverse-engineering - 您可以对指向 Application Insights 的 Saved Query 链接进行逆向工程吗?

C# Silverlight WebClient 获取响应的内容类型?

c# - 在 C# 中遍历泛型列表

javascript - 每个 JS 文件在打开并保存在 Azure 上之前都会引发错误

azure - 如何使用Azure(个人)帐户设置VSTS(企业)帐户以进行持续部署

azure - 我可以在 Azure Application Insight 中查看 Http 队列长度吗?

visual-studio-2013 - 阻止 Application Insights 发布到调试控制台