Skip to content

Commit c8a8a2d

Browse files
committed
added queue length metrics #16 #17
1 parent 4d6901c commit c8a8a2d

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/NTorSpectator.Observer/Services/SpectatorJob.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
using NTorSpectator.Observer.TorIntegration;
22
using NTorSpectator.Services;
33
using NTorSpectator.Services.Models;
4+
using Prometheus;
45
using Quartz;
56

67
namespace NTorSpectator.Observer.Services;
78

89
public class SpectatorJob : IJob
910
{
11+
private static readonly Gauge QueueLength = Metrics.CreateGauge("sites_queue_length", "Length of the queue left to observe");
1012
private readonly ILogger<SpectatorJob> _logger;
1113
private readonly ISitesCatalogue _sitesCatalogue;
1214
private readonly TorControlManager _torControl;
@@ -29,6 +31,7 @@ public async Task Execute(IJobExecutionContext context)
2931
var siteQueue = new Queue<QueuedSite>(sites.Select(x => new QueuedSite(x, 0)));
3032
while(siteQueue.TryDequeue(out var queuedSite))
3133
{
34+
QueueLength.Set(siteQueue.Count);
3235
using var _ = _logger.BeginScope(new Dictionary<string, object> { { "HiddenService", queuedSite.Site.SiteUri } });
3336
_logger.LogDebug("Starting observations on the next site");
3437
try

0 commit comments

Comments
 (0)