Skip to content

Commit 1175a33

Browse files
JamesNKdrewnoakes
andauthored
Fix histogram chart calculation (#1968)
Co-authored-by: Drew Noakes <[email protected]>
1 parent 22066e8 commit 1175a33

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,13 +170,18 @@ protected override async Task OnParametersSetAsync()
170170

171171
private OtlpInstrument? GetInstrument()
172172
{
173+
var endDate = DateTime.UtcNow;
174+
// Get more data than is being displayed. Histogram graph uses some historical data to calculate bucket counts.
175+
// It's ok to get more data than is needed here. An additional date filter is applied when building chart values.
176+
var startDate = endDate.Subtract(Duration + TimeSpan.FromSeconds(30));
177+
173178
var instrument = TelemetryRepository.GetInstrument(new GetInstrumentRequest
174179
{
175180
ApplicationServiceId = ApplicationId,
176181
MeterName = MeterName,
177182
InstrumentName = InstrumentName,
178-
StartTime = DateTime.UtcNow.Subtract(Duration),
179-
EndTime = DateTime.UtcNow,
183+
StartTime = startDate,
184+
EndTime = endDate,
180185
});
181186

182187
if (instrument == null)

0 commit comments

Comments
 (0)