Add support for System.Diagnostics.Metrics in dotnet-monitor's collector - #3587
Conversation
…3529) * Got basic counter rate end-to-end working - currently in a broken state as I investigate other types of metrics * Leftovers from previous commit * Gauges working for systems diagnostics metrics * Added in histogram, adding in options for maxHistograms and maxTimeSeries * Added in error payloads for logging purposes * Temporarily changed visibility for testing - this may be reverted later * Now handling multiple sessions * Added filtering for counters, instead of allowing all counters for a provider to go through. * Handle observable... errors * Some cleanup, added error event check * Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20221129.1 (#3528) [main] Update dependencies from dotnet/source-build-reference-packages Co-authored-by: dotnet-maestro[bot] <42748379+dotnet-maestro[bot]@users.noreply.github.com>
Merge main to feature branch
* Fix ICountersLogger contract * MetadataUpdates * Fixup api protection levels * Fixup tests and add CounterEnded payload * Fixup metadata parsing
Merge main to feature/eventPipeMeters
merge main to feature/eventPipeMeters
Minor branch cleanup
noahfalk
left a comment
There was a problem hiding this comment.
This seems fine so far to me!
|
Sweet this is one of the big gaps with the new Metrics API that I wanted to get addressed and I was going to come talk to you all about it. I'm very happy to see you beat me to it! |
PR for feature branch
noahfalk
left a comment
There was a problem hiding this comment.
LGTM modulo a few inline comments
Convert Histogram to single payload
Merge main to eventPipeMeters
Fix issue with empty quantiles
| } | ||
|
|
||
| if (commaIndex < 0) | ||
| if (string.IsNullOrEmpty(quantilesText)) |
There was a problem hiding this comment.
@noahfalk after histogram values are no longer reported regularly in the app, the quantiles here become empty. is this by design?
There was a problem hiding this comment.
Yep, the app hasn't disposed the Histogram and also hasn't recorded any data within the measurement interval then by design you get an event where the quantiles string is empty. There is a test case for that behavior here: https://github.com/dotnet/runtime/blob/main/src/libraries/System.Diagnostics.DiagnosticSource/tests/MetricEventSourceTests.cs#L374
When doing the design initially I thought that sending an explicit event with empty content would let tools know with confidence that the app didn't produce data whereas if an event is absent it is ambiguous what the app did.
There was a problem hiding this comment.
Should this then return a CounterEndedPayload instance?
There was a problem hiding this comment.
I'll double check this behavior, but I believe it produces more data if more data occurs. I will change our pipeline to produce the event with no quantiles, and we can simply discard them during consumption.
There was a problem hiding this comment.
Yes, the MetricEventSource events should behave the way you are describing Wiktor. You could choose to model it different ways when you are processing it but looking at Prometheus probably provides a good point of comparison. You could make a Prometheus.NET histogram, record no data, and see what shows up on the metrics endpoint.
| } | ||
|
|
||
| // Copied from dotnet-counters | ||
| public CounterPayload(string providerName, string name, string displayName, string displayUnits, string metadata, double value, DateTime timestamp, string type, EventType eventType) |
There was a problem hiding this comment.
displayName is not used; either remove it, or (preferably) have it set the DisplayName property, change the property to get-only, and call all upstreams to pass in the coerced display name value.
There was a problem hiding this comment.
There is a separate change for cleaning up all these constructors.
| } | ||
|
|
||
| if (commaIndex < 0) | ||
| if (string.IsNullOrEmpty(quantilesText)) |
There was a problem hiding this comment.
Should this then return a CounterEndedPayload instance?
@kkeirstead completed most of code here.
Note: Currently the code duplicates the data model from the original dotnet-counters work.
Note there is additional work that is built on top of this feature branch