-
Notifications
You must be signed in to change notification settings - Fork 356
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dotnet-counters does not report values from multiple Metrics Meters with distinct tags #4564
Comments
I'm pretty sure are hitting a known issue tracked here and the current plan is to fix it during .NET 9 for the scenario involving dotnet-counters. I wouldn't take that as a promise, but I think its likely. Just so you are aware OpenTelemetry.NET also doesn't support multiple Meters distinguished solely by tags and at the moment the OTel spec officially says that isn't supported. Others have also encountered this issue and asked them to please support it in the future. I believe they are looking into it but if you care about OpenTelmetry support you can always open an issue in OTel.NET repo. The changes needed to make dotnet-counters and OTel support this are fully independent of one another. Hope that helps explain where things are! |
Damn, that's kind of annoying. Guess I have to change my library code then. Thanks though! |
In .NET 8.0 we added tags on Meters and Instruments but MetricsEventSource only included the names when emitting value publishing events. This made it ambiguous when there was more than one Meter or Instrument with the same name. In 9.0 MetricsEventSource started included InstrumentIDs in the BeginInstrumentReporting events and in the value publishing events that provides a stronger correlation identifier. This change consumes the IDs in those events within Microsoft.Diagnostics.Monitoring.EventPipe, allowing dotnet-counters (and presumably dotnet-monitor too) to track time series that differ only by the tags provided to the Meter/Instrument constructors. I also re-enabled a disabled test that got broken .NET 9.0 added the System.Runtime Meter. Fixes dotnet#4843, dotnet#4564
In .NET 8.0 we added tags on Meters and Instruments but MetricsEventSource only included the names when emitting value publishing events. This made it ambiguous when there was more than one Meter or Instrument with the same name. In 9.0 MetricsEventSource started included InstrumentIDs in the BeginInstrumentReporting events and in the value publishing events that provides a stronger correlation identifier. This change consumes the IDs in those events within Microsoft.Diagnostics.Monitoring.EventPipe, allowing dotnet-counters (and presumably dotnet-monitor too) to track time series that differ only by the tags provided to the Meter/Instrument constructors. I also re-enabled a disabled test that got broken when .NET 9.0 added the System.Runtime Meter. Fixes #4843, #4564
Closing via #4938 |
Description
I was adding built-in support for
System.Diagnostics.Metrics
to a library I maintain. In the library I want it to be possible to report separate metrics for each instance of a network socket, so I made each object instantiate aMeter
and have an API for passing in a list oftags
to said meter to distinguish them. Then I can just instantiate a new observable counter/gauge for each property I want to report and it looks pretty nice. For reference, here is the code.However,
dotnet counters
only seems to report the metrics from one meter. In this example I have a separate meter withbind=::
andbind=0.0.0.0
created, but I only get results forbind=::
.Cross-referencing against
prometheus-net
1, these values are correctly reported however.I already noticed that the same thing happened if I created two separate instruments with identical name but different tags, but I figured that one was at least somewhat reasonable. Instead I ended up just using callback-form that returns multiple measurements for the counter that needed to report tags.
Is this intended behavior or a bug? If it's intended behavior, I suppose I should make a static
Meter
instance and use it for all peers, but that would be rather annoying and inflexible IMO.Configuration
Tool:
dotnet-counters
, version8.0.510501+8c08c89a0643d31db91e119b1adb463be3e0ffe5
.NET runtime I'm testing against: .NET 8.0.3
OS: Windows 11 Pro, 23H2, build 22631.3296
Architecture: x64
Environment: just running stuff directly from my IDE/terminal, no containers or whatever.
dotnet info
Regression?
Meter/instrument tags are a new feature in .NET 8, so I doubt it. I had trouble before because the tags wouldn't show up at all, but that was fixed by just making sure my
dotnet-counters
was at the latest version.Footnotes
I just made a PR to make prometheus-net respect meter/instrument tags. ↩
The text was updated successfully, but these errors were encountered: