Reputation: 1656
Is it possible to capture performance counter values for the current process/app? I am trying to capture metrics about my running web job, such as % TIme in GC, Gen N heap size, thread contention Rate / Sec, etc. I see Application Insights can capture these kind of metrics when enabled in my web site.
var category = ".NET CLR Memory";
var counter = "% Time in GC";
var instance = Process.GetCurrentProcess().ProcessName;
var pc = new PerformanceCounter(category, counter, instance, true);
I understand why this would fail as the Auzre/kudu runtime sandbox needs to ensure the instance is my process not some other customer's process. Is there a way to get access to my process' counters so I can report on/collect them? I would like the collection to occur from within the process.
Upvotes: 1
Views: 425
Reputation: 15042
At this time, it's not possible to collect performance counters due to sandbox limitations, as you mentioned. We're looking into ways to make this possible in a secure way, but don't have any timelines to share.
Your best bet at this point may be to use application insights, which is currently the recommended way to collect diagnostics for your app (they have solutions for pretty much any app type - not just web apps): https://azure.microsoft.com/en-us/documentation/services/application-insights/
Upvotes: 1