update metrics more often

This commit is contained in:
rootdarkarchon
2024-01-14 12:28:04 +01:00
parent 4c1131a988
commit a66e93c901

View File

@@ -125,7 +125,20 @@ public class RequestQueueService : IHostedService
private async void ProcessQueue(object src, ElapsedEventArgs e) private async void ProcessQueue(object src, ElapsedEventArgs e)
{ {
if (_queueProcessingSemaphore.CurrentCount == 0) return; _logger.LogDebug("Periodic Processing Queue Start");
_metrics.SetGaugeTo(MetricsAPI.GaugeQueueFree, _userQueueRequests.Count(c => c == null));
_metrics.SetGaugeTo(MetricsAPI.GaugeQueueActive, _userQueueRequests.Count(c => c != null && c.IsActive));
_metrics.SetGaugeTo(MetricsAPI.GaugeQueueInactive, _userQueueRequests.Count(c => c != null && !c.IsActive));
_metrics.SetGaugeTo(MetricsAPI.GaugeDownloadQueue, _queue.Count(q => !q.IsCancelled));
_metrics.SetGaugeTo(MetricsAPI.GaugeDownloadQueueCancelled, _queue.Count(q => q.IsCancelled));
_metrics.SetGaugeTo(MetricsAPI.GaugeDownloadPriorityQueue, _priorityQueue.Count(q => !q.IsCancelled));
_metrics.SetGaugeTo(MetricsAPI.GaugeDownloadPriorityQueueCancelled, _priorityQueue.Count(q => q.IsCancelled));
if (_queueProcessingSemaphore.CurrentCount == 0)
{
_logger.LogDebug("Aborting Periodic Processing Queue, processing still running");
return;
}
await _queueProcessingSemaphore.WaitAsync().ConfigureAwait(false); await _queueProcessingSemaphore.WaitAsync().ConfigureAwait(false);
@@ -186,14 +199,7 @@ public class RequestQueueService : IHostedService
finally finally
{ {
_queueProcessingSemaphore.Release(); _queueProcessingSemaphore.Release();
} _logger.LogDebug("Periodic Processing Queue End");
}
_metrics.SetGaugeTo(MetricsAPI.GaugeQueueFree, _userQueueRequests.Count(c => c == null));
_metrics.SetGaugeTo(MetricsAPI.GaugeQueueActive, _userQueueRequests.Count(c => c != null && c.IsActive));
_metrics.SetGaugeTo(MetricsAPI.GaugeQueueInactive, _userQueueRequests.Count(c => c != null && !c.IsActive));
_metrics.SetGaugeTo(MetricsAPI.GaugeDownloadQueue, _queue.Count(q => !q.IsCancelled));
_metrics.SetGaugeTo(MetricsAPI.GaugeDownloadQueueCancelled, _queue.Count(q => q.IsCancelled));
_metrics.SetGaugeTo(MetricsAPI.GaugeDownloadPriorityQueue, _priorityQueue.Count(q => !q.IsCancelled));
_metrics.SetGaugeTo(MetricsAPI.GaugeDownloadPriorityQueueCancelled, _priorityQueue.Count(q => q.IsCancelled));
} }
} }