diff options
| author | JP Dillingham <jp@dillingham.me> | 2022-08-28 21:13:35 -0500 |
|---|---|---|
| committer | JP Dillingham <jp@dillingham.me> | 2022-08-28 21:13:35 -0500 |
| commit | 76f40ff5f2581da82fe710fb7f0fd15cd96bbdb3 (patch) | |
| tree | 8546e7bb39238c6336d5db83cd6a890a6a6e7e09 /src | |
| parent | 123a0aade47ed7be8b508417c1b7062dcd6f1a07 (diff) | |
| download | slskd-76f40ff5f2581da82fe710fb7f0fd15cd96bbdb3.tar.gz | |
average browse response latency also
Diffstat (limited to 'src')
| -rw-r--r-- | src/slskd/Application.cs | 1 | ||||
| -rw-r--r-- | src/slskd/Core/Metrics.cs | 17 |
2 files changed, 13 insertions, 5 deletions
diff --git a/src/slskd/Application.cs b/src/slskd/Application.cs index 8f033704..e9b00c6b 100644 --- a/src/slskd/Application.cs +++ b/src/slskd/Application.cs @@ -421,6 +421,7 @@ namespace slskd sw.Stop(); Metrics.Browse.ResponseLatency.Observe(sw.ElapsedMilliseconds); + Metrics.Browse.CurrentResponseLatency.Update(sw.ElapsedMilliseconds); Metrics.Browse.ResponsesSent.Inc(1); return new BrowseResponse(directories); diff --git a/src/slskd/Core/Metrics.cs b/src/slskd/Core/Metrics.cs index d91920f6..98db91d2 100644 --- a/src/slskd/Core/Metrics.cs +++ b/src/slskd/Core/Metrics.cs @@ -55,11 +55,6 @@ namespace slskd public static class Browse { /// <summary> - /// Gets a counter representing the total number of browse responses sent. - /// </summary> - public static Counter ResponsesSent { get; } = Prometheus.Metrics.CreateCounter("slskd_browse_responses_sent", "Total number of browse responses sent"); - - /// <summary> /// Gets a histogram representing the time taken to resolve a response to an incoming browse request, in milliseconds. /// </summary> public static Histogram ResponseLatency { get; } = Prometheus.Metrics.CreateHistogram( @@ -69,6 +64,18 @@ namespace slskd { Buckets = Histogram.ExponentialBuckets(1, 2, 10), }); + + /// <summary> + /// Gets an EMA representing the average time taken to resolve a response to an incoming search request, in milliseconds. + /// </summary> + public static ExponentialMovingAverage CurrentResponseLatency { get; } = new ExponentialMovingAverage(smoothingFactor: 0.5, onUpdate: value => CurrentResponseLatencyGauge.Set(value)); + + /// <summary> + /// Gets a counter representing the total number of browse responses sent. + /// </summary> + public static Counter ResponsesSent { get; } = Prometheus.Metrics.CreateCounter("slskd_browse_responses_sent", "Total number of browse responses sent"); + + private static Gauge CurrentResponseLatencyGauge { get; } = Prometheus.Metrics.CreateGauge("slskd_browse_response_latency_current", "The average time taken to resolve a response to an incoming browse request, in milliseconds"); } public static class DistributedNetwork |
