Skip to content

How do I discover what counters are available for dotnet-counters? #79372

@samsp-msft

Description

@samsp-msft

If a tree falls in a forest and nobody is listening, does it make a sound?

If you need to upfront register your ears to listen to the sound of Tree.Falling then that question becomes more complicated.

dotnet-counters has a List mode which appears to be a static list, a la help. This is better than nothing, but it doesn't help much as I don't think it has been updated since 3.1. For example, we added a bunch of counters for networking, that I don't believe are listed.

There should be a mode of dotnet-counters that will adapt itself and listen to any counters that are registered as the application is run. For example, something like:

dotnet-counters monitor -process-id 12345 -all-counters

Is this the most performance efficient way of running the application - no - but it'll make it much easier for developers/SRE to see what counters are available, and for when they are writing their own counters to be able to diagnose if they have made typos etc.

Activity

ghost

ghost commented on Dec 8, 2022

@ghost

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

ghost added
untriagedNew issue has not been triaged by the area owner
on Dec 8, 2022
MihaZupan

MihaZupan commented on Dec 8, 2022

@MihaZupan
Member

The list of networking counters is kept up to date: https://github.com/dotnet/diagnostics/blob/433fd6a073fe29895c01ed1a70d5cba568a0e070/src/Tools/dotnet-counters/KnownData.cs#L91-L161
(that said if the tool could do it automagically I wouldn't complain 🙂)

pinkfloydx33

pinkfloydx33 commented on Dec 8, 2022

@pinkfloydx33

It says the maxVersion/runtimeVersion is 6.0 and only includes 7.0 as a supported version in a handful of places. Perhaps that's why?

samsp-msft

samsp-msft commented on Dec 9, 2022

@samsp-msft
Author

The latest version of dotnet-counters seems to be 6.0.351802, which could well be before @MihaZupan's changes were included.

However that still doesn't solve the problem that counters can be added by any code including the app and 3rd party libraries, and so having it be able to enumerate all the counters actually be used would be very useful.

added
enhancementProduct code improvement that does NOT require public API changes/additions
and removed
untriagedNew issue has not been triaged by the area owner
on Dec 12, 2022
added this to the 8.0.0 milestone on Dec 13, 2022
samsp-msft

samsp-msft commented on Jan 31, 2023

@samsp-msft
Author

I ended up creating a utility to enumerate the counters and events exposed in a process

https://gist.github.com/samsp-msft/cb4ba1e5bb4de0c6bb3aae5ecbeac162

To use:

var enumerateEvents = new EventEnumerator();
app.MapGet("/Events", () => enumerateEvents.DumpEvents());
modified the milestones: 8.0.0, 9.0.0 on Jul 17, 2023

7 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area-System.DiagnosticsenhancementProduct code improvement that does NOT require public API changes/additions

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions

    How do I discover what counters are available for dotnet-counters? · Issue #79372 · dotnet/runtime