Add a counter to Stress app#9432
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds a counter feature to the Stress playground app by registering a new hosted service and corresponding metrics meter. Key changes include:
- Registering CounterMetrics as a hosted service and adding its corresponding meter in Program.cs.
- Introducing a new CounterMetrics class that creates and increments a counter metric in a background loop.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| playground/Stress/Stress.TelemetryService/Program.cs | Added registration for the CounterMetrics hosted service and meter. |
| playground/Stress/Stress.TelemetryService/CounterMetrics.cs | New service that implements a counter metric using a background task loop. |
Comments suppressed due to low confidence (1)
playground/Stress/Stress.TelemetryService/CounterMetrics.cs:16
- [nitpick] The metric name 'run.done.new.count' could be made more descriptive. Consider renaming it to something like 'counter.completedRuns' to better convey its purpose.
name: "run.done.new.count",
| for (var i = 0; i < 1000000; i++) | ||
| { | ||
| counter.Add(1); | ||
| await Task.Delay(20, cancellationToken); |
There was a problem hiding this comment.
Extracting the delay duration (20 milliseconds) into a named constant could enhance readability and maintainability.
| await Task.Delay(20, cancellationToken); | |
| await Task.Delay(DelayDurationMilliseconds, cancellationToken); |
|
take a look at these screen shots: in the first one it said there was 585 new posts at 8:00:14 and 697 new posts at 8:00:34 Sometimes it even changes a value from past as i said in #9251 |
@inlineHamed please show the graph view as well |






Description
While investigating #9251, I ntoiced we were missing a counter in the stress playground app.
Checklist
<remarks />and<code />elements on your triple slash comments?doc-ideatemplatebreaking-changetemplatediagnostictemplate