Skip to content

Commit

Permalink
[release/8.0-preview3] Fix histogram chart calculation (#1993)
Browse files Browse the repository at this point in the history
* Fix histogram chart calculation

* Comment

* Update src/Aspire.Dashboard/Components/Controls/ChartContainer.razor.cs

Co-authored-by: Drew Noakes <git@drewnoakes.com>

* Update src/Aspire.Dashboard/Components/Controls/ChartContainer.razor.cs

---------

Co-authored-by: James Newton-King <james@newtonking.com>
Co-authored-by: Drew Noakes <git@drewnoakes.com>
  • Loading branch information
3 people committed Jan 31, 2024
1 parent bc85854 commit 0e735d2
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,18 @@ protected override async Task OnParametersSetAsync()

private OtlpInstrument? GetInstrument()
{
var endDate = DateTime.UtcNow;
// Get more data than is being displayed. Histogram graph uses some historical data to calculate bucket counts.
// It's ok to get more data than is needed here. An additional date filter is applied when building chart values.
var startDate = endDate.Subtract(Duration + TimeSpan.FromSeconds(30));

var instrument = TelemetryRepository.GetInstrument(new GetInstrumentRequest
{
ApplicationServiceId = ApplicationId,
MeterName = MeterName,
InstrumentName = InstrumentName,
StartTime = DateTime.UtcNow.Subtract(Duration),
EndTime = DateTime.UtcNow,
StartTime = startDate,
EndTime = endDate,
});

if (instrument == null)
Expand Down

0 comments on commit 0e735d2

Please sign in to comment.