Skip to content

Commit 1d14789

Browse files
committed
added site observation metric #18
1 parent f95c729 commit 1d14789

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/NTorSpectator.Observer/Services/SpectatorJob.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@ public class SpectatorJob : IJob
1010
{
1111
private static readonly Gauge QueueLength = Metrics.CreateGauge("sites_queue_length", "Length of the queue left to observe");
1212
private static readonly Counter ObservationsCount = Metrics.CreateCounter("observations", "counts all observations");
13-
private static readonly Counter RetriesCount = Metrics.CreateCounter("enqueued_retries", "counts retires");
13+
private static readonly Counter RetriesCount = Metrics.CreateCounter("enqueued_retries", "counts retires");
14+
private static readonly Histogram RequestDuration = Metrics.CreateHistogram("observation_duration", "duration of site observation",
15+
new HistogramConfiguration
16+
{
17+
Buckets = Histogram.LinearBuckets(0.5, 0.5, 20)
18+
});
1419

1520
private readonly ILogger<SpectatorJob> _logger;
1621
private readonly ISitesCatalogue _sitesCatalogue;
@@ -69,6 +74,7 @@ private record QueuedSite(Site Site, int ObservationsCount);
6974

7075
private async Task<TorWatchResults> ObserveSite(string site)
7176
{
77+
using var _ = RequestDuration.NewTimer();
7278
var torReply = await _torControl.HsFetch(site);
7379
var positive = torReply.Count(x => x.Action == HsDescAction.Received);
7480
var negative = torReply.Count(x => x.Action == HsDescAction.Failed);

0 commit comments

Comments
 (0)