fix some existing issues

This commit is contained in:
2026-01-17 08:00:58 +09:00
parent 8be0811b4a
commit b57d54d69c
4 changed files with 191 additions and 18 deletions

View File

@@ -131,7 +131,10 @@ public sealed class PerformanceCollectorService : IHostedService
DrawSeparator(sb, longestCounterName);
}
var pastEntries = limitBySeconds > 0 ? entry.Value.Where(e => e.Item1.AddMinutes(limitBySeconds / 60.0d) >= TimeOnly.FromDateTime(DateTime.Now)).ToList() : [.. entry.Value];
var snapshot = entry.Value.Snapshot();
var pastEntries = limitBySeconds > 0
? snapshot.Where(e => e.Item1.AddMinutes(limitBySeconds / 60.0d) >= TimeOnly.FromDateTime(DateTime.Now)).ToList()
: snapshot;
if (pastEntries.Any())
{
@@ -189,7 +192,11 @@ public sealed class PerformanceCollectorService : IHostedService
{
try
{
var last = entries.Value.ToList()[^1];
if (!entries.Value.TryGetLast(out var last))
{
continue;
}
if (last.Item1.AddMinutes(10) < TimeOnly.FromDateTime(DateTime.Now) && !PerformanceCounters.TryRemove(entries.Key, out _))
{
_logger.LogDebug("Could not remove performance counter {counter}", entries.Key);