dotnet / aspire

An opinionated, cloud ready stack for building observable, production ready, distributed applications in .NET
https://learn.microsoft.com/dotnet/aspire
MIT License
3.37k stars 348 forks source link

Dashboard shows the sum of measurement values of Gauge #2884

Open KalleOlaviNiemitalo opened 3 months ago

KalleOlaviNiemitalo commented 3 months ago

I have a service in which an ObservableGauge\<double> instrument monitors approximately 90 components and has an observeValues callback that returns the latest processing duration of each, as IEnumerable\<Measurement\<double>>. Each measurement also has a tag whose value is the name of the component. When I make the service export these to the Aspire dashboard over OTLP and don't set any filters in the dashboard, both the "Graph" and "Table" options in the dashboard apparently show sums of the durations. It would be better to show the maximum or the average, rather than the sum. According to OpenTelemetry Supplementary Guidelines for Metrics, Asynchronous Gauge values are not additive.

KalleOlaviNiemitalo commented 3 months ago

I guess the measurement values are first collected here: https://github.com/dotnet/aspire/blob/692dc41a65da572a7df25d53a9f2880afe59fdd8/src/Aspire.Dashboard/Otlp/Model/OtlpInstrument.cs#L30-L35

and then summed here: https://github.com/dotnet/aspire/blob/692dc41a65da572a7df25d53a9f2880afe59fdd8/src/Aspire.Dashboard/Components/Controls/Chart/ChartBase.cs#L369

There is an OtlpInstrumentType.Gauge constant but it is treated as equivalent to OtlpInstrumentType.Sum everywhere, including here: https://github.com/dotnet/aspire/blob/692dc41a65da572a7df25d53a9f2880afe59fdd8/src/Aspire.Dashboard/Components/Controls/Chart/ChartBase.cs#L402-L405

JamesNK commented 3 months ago

Hmmm, I don't think there is a good easy choice here. Max, min, or average are all a little confusing.

I think the right choice here is to show different series (i.e. different lines) but that won't scale well with many dimensions. Alternatively, change the dimension selected from checkboxes to a dropdown. Either of this choices is a reasonably big change. I'm not sure if we'll do it for the first release.

The workaround is to only select one dimension, so values aren't added together.

KalleOlaviNiemitalo commented 3 months ago

Draw each of min, max, and average as curves in the graph perhaps? Or have a drop-down list for selecting the aggregate function.