3
votes

I'm following these instructions to add App Insights to a Windows desktop app. I added some TrackMetric and TrackException calls to my code, and the data from those are showing up in the portal just fine, so I know the basic plumbing is working.

Based on these instructions, I then added the AI.Web NuGet package to my project (yes, I know that sounds odd, but it's specifically recommended) and disabled all except the following modules/initializers in the config file:

  • DiagnosticsTelemetryModule
  • DependencyTrackingTelemetryModule
  • PerformanceCollectorModule
  • DeviceTelemetryInitializer

The additional device info started showing up in my telemetry data, so I know the app is picking up the config file settings at least.

Unfortunately, no matter what I do, none of the standard performance counter metrics are showing up.

Is there something else I need to do to enable perf counter collection in a desktop app?

Thanks in advance for any, er, insights... :)

EDIT: By "standard performance counters" I mean the Windows performance counters PerformanceCollectorModule supposedly tracks by default, according to the instructions linked earlier, which state:

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...

It's pretty clear that I should not have to add the standard ones to the config file -- only any additional counters I want to include.

2
you don't need to add the web package, the perf counter stuff can be installed independently by just installing nuget.org/packages/…John Gardner
and which part of the instructions for perf collector did you do? did you either in config file or code set up which perf counters you wanted it to monitor? if so, can you add that to your question here?John Gardner

2 Answers

2
votes

Ideally, you should be able to use just the Perf Counter Collector nuget package on top of the base Application Insights package for your app.

You'd still have to set up which perf counters you want to monitor either in your appinsights.config file, or via code, which is documented in the instructions you linked to, like:

<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>

I believe the web sdk just sets up a bunch of ASP.NET pipeline / w3wp perf counters which wouldn't do anything in a standard windows app.

2
votes

Make sure that the account (that your application is running under) does have access to Performance counters on that machine (usually it should just be a member of Performance Monitor Users group).