oracle / dotnet-db-samples

.NET code samples for Oracle database developers #OracleDotNet
http://otn.oracle.com/dotnet
MIT License
408 stars 190 forks source link

How to find the instance name of a performance counter when running under IIS #298

Closed tronda closed 12 months ago

tronda commented 1 year ago

I have a .NET Framework ASP.NET WebAPI running under IIS. For this application I would like it to report performance counter values as metrics to an OpenTelemetry Collector. The challenge is how I can construct the instance name at runtime when running under IIS. I see from the simple sample how this can be done, but I don't see how I can achieve the same from a running WebAPI application (one among several other WebAPI applications on the same machine).

When I open PerfMon in Windows I see the instance name being similar to this: _lm_w3svc_1_root_aaaa_bbbb-w...[12100,2]. I have not found a way to construct this instance name at runtime.

alexkeh commented 1 year ago

This question may be more applicable to an ASP.NET forum to ask in terms of how others have identified the specific web app instance from PerfMon.

I suppose you could retrieve the instance of every web app running, then check whether it has the ODP.NET counter being published. If so, you've found the instance you're looking for.