dotnet / dotnet/diagnostics

dotnet-counters doesn't display a counter until the app records a measurement

Open
#3,743 2 comments 0 reactions 0 assignees View on GitHub
dotnet-counters enhancement
Dominant language
C++
Stars
1.3k
Forks
404
Avg merge
2d 3h
Merged PRs (30d)
38

Description

### Description

I'm experimenting with adding metrics to ASP.NET Core (and eventually alongside most or all existing event source counters). See https://github.com/dotnet/aspnetcore/pull/46834

I noticed that dotnet-counters doesn't display a metrics counters until it is used. For example, hosting counters that record a HTTP request is starting, stopping, latency, etc, aren't displayed until a web request is made. That is confusing to users who would expect to see the counters but with zero values. For example, they'd expect to see the app has `requests-failed = 0` on startup.

Screen recording showing that the `Microsoft.AspNetCore.Hosting.Temp` counters (using metrics) aren't displayed until a HTTP request is made:

![dotnet-counters-counters-display-on-use](https://user-images.githubusercontent.com/303201/224949673-e96fb295-76f3-46b0-b77b-2805703ae0c2.gif)

### Configuration

.NET 8 web app publishing counters.

```
dotnet-counters --version
7.0.410101+f99383213ea19741908f5aa3cf0ed400db2e5f0a
```

### Regression?

Unknown

### Other information

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.