dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.42k stars 4.76k forks source link

PerformanceCounter.NextValue() always return 0 for "HTTP Service Request Queues" MaxQueueItemAge #109956

Open vsfeedback opened 3 days ago

vsfeedback commented 3 days ago

This issue has been moved from a ticket on Developer Community.


[severity:I'm unable to use this version] Customer Support Team CSS got customer reporting this issue: We followed the doc: https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.performancecounter.nextvalue?view=net-8.0 to read Perf counter "HTTP Service Request Queues" MaxQueueItemAge.

The Code and the doc is quite clear and it works for other Perf Counters, except this "HTTP Service Request Queues" MaxQueueItemAge.

static void InitPerfCountersMeasure()

{

var perfCateogry = new PerformanceCounterCategory(@"HTTP Service Request Queues");

maxQueueAgeCounter = new PerformanceCounter(@"HTTP Service Request Queues", "MaxQueueItemAge", "Johnson Controls Rewrite", true); // this Perf counter does not work

Console.WriteLine($"initial value: {maxQueueAgeCounter.NextValue()}");

queueSizeCounter = new PerformanceCounter(@"HTTP Service Request Queues", "CurrentQueueSize", "Johnson Controls Rewrite", true); // this Perf Counter works no issue

origMaxQueueAge = maxQueueAgeCounter.NextSample();

perfCounterTimer = new System.Timers.Timer(1000);

//perfCounterTimer.AutoReset = false;

perfCounterTimer.Elapsed += PerfCountersMeasure;

perfCounterTimer.Start();

}

static void PerfCountersMeasure(object source, ElapsedEventArgs e)

{

//WriteLog("-----------------------------------------------");

WriteLog($"maxQueueAge: {maxQueueAgeCounter.NextValue()}");

WriteLog($"maxQueueAge orig raw value: {origMaxQueueAge.RawValue}");

WriteLog($"queueSize: {queueSizeCounter.NextValue()}");

WriteLog("-----------------------------------------------");

}

the QueueSize is increasing as the program keep sending requests there. but the "HTTP Service Request Queues" MaxQueueItemAge always got 0 back.


Original Comments

Feedback Bot on 12/09/2024, 02:32 AM:

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.

dotnet-policy-service[bot] commented 2 days ago

Tagging subscribers to this area: @dotnet/area-system-diagnostics-performancecounter See info in area-owners.md if you want to be subscribed.