From 75c96b1d5ffef182428fa752507e6fe7a1b5a338 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Thu, 25 Aug 2022 20:30:25 -0500 Subject: stub metrics --- src/slskd/Core/Metrics.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/slskd/Core/Metrics.cs (limited to 'src/slskd/Core') diff --git a/src/slskd/Core/Metrics.cs b/src/slskd/Core/Metrics.cs new file mode 100644 index 00000000..51fc75db --- /dev/null +++ b/src/slskd/Core/Metrics.cs @@ -0,0 +1,18 @@ +using Prometheus; + +namespace slskd +{ + public static class Metrics + { + public static Histogram SearchResponseLatency { get; } = Prometheus.Metrics + .CreateHistogram("slskd_search_response_latency", "Histogram of received order values (in USD).", + new HistogramConfiguration + { + // We divide measurements in 10 buckets of $100 each, up to $1000. + Buckets = Histogram.ExponentialBuckets(1, 2, 10), + }); + + public static Counter SearchRequestsReceived { get; } = Prometheus.Metrics.CreateCounter("slskd_search_requests_received", "total number of search requests"); + public static Counter SearchResponsesSent { get; } = Prometheus.Metrics.CreateCounter("slskd_search_responses_sent", "total number of search responses sent"); + } +} -- cgit v1.2.3 From c9ae44e33e3d8b7b8ab8b11f3f094e05dfe9fea5 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Thu, 25 Aug 2022 22:01:50 -0500 Subject: add Measure() overloads --- src/slskd/Core/Metrics.cs | 47 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 42 insertions(+), 5 deletions(-) (limited to 'src/slskd/Core') diff --git a/src/slskd/Core/Metrics.cs b/src/slskd/Core/Metrics.cs index 51fc75db..e3fbfe01 100644 --- a/src/slskd/Core/Metrics.cs +++ b/src/slskd/Core/Metrics.cs @@ -1,18 +1,55 @@ -using Prometheus; +using System; +using System.Diagnostics; +using System.Threading.Tasks; +using Prometheus; namespace slskd { public static class Metrics { public static Histogram SearchResponseLatency { get; } = Prometheus.Metrics - .CreateHistogram("slskd_search_response_latency", "Histogram of received order values (in USD).", + .CreateHistogram($"slskd_search_response_latency", "The time taken to resolve a response to an incoming search request, in milliseconds", new HistogramConfiguration { - // We divide measurements in 10 buckets of $100 each, up to $1000. Buckets = Histogram.ExponentialBuckets(1, 2, 10), }); - public static Counter SearchRequestsReceived { get; } = Prometheus.Metrics.CreateCounter("slskd_search_requests_received", "total number of search requests"); - public static Counter SearchResponsesSent { get; } = Prometheus.Metrics.CreateCounter("slskd_search_responses_sent", "total number of search responses sent"); + public static Counter SearchRequestsReceived { get; } = Prometheus.Metrics.CreateCounter("slskd_search_requests_received", "Total number of search requests received"); + public static Counter SearchResponsesSent { get; } = Prometheus.Metrics.CreateCounter("slskd_search_responses_sent", "Total number of search responses sent"); + + public static Counter BrowseResponsesSent { get; } = Prometheus.Metrics.CreateCounter("slskd_browse_responses_sent", "Total number of browse responses sent"); + public static Histogram BrowseResponseLatency { get; } = Prometheus.Metrics.CreateHistogram("slskd_browse_response_latency", "The time taken to resolve a response to an incoming browse request, in milliseconds", + new HistogramConfiguration + { + Buckets = Histogram.ExponentialBuckets(1, 2, 10), + }); + + public static T Measure(Histogram histogram, Func action) + { + var sw = new Stopwatch(); + sw.Start(); + + var result = action(); + + sw.Stop(); + + histogram.Observe(sw.ElapsedMilliseconds); + + return result; + } + + public static async Task MeasureAsync(Histogram histogram, Func> action) + { + var sw = new Stopwatch(); + sw.Start(); + + var result = await action(); + + sw.Stop(); + + histogram.Observe(sw.ElapsedMilliseconds); + + return result; + } } } -- cgit v1.2.3 From 5f6ac691a50deab1a3cf76cc16ac5e941f86580f Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Thu, 25 Aug 2022 22:16:14 -0500 Subject: clean up --- src/slskd/Core/Metrics.cs | 76 ++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 65 insertions(+), 11 deletions(-) (limited to 'src/slskd/Core') diff --git a/src/slskd/Core/Metrics.cs b/src/slskd/Core/Metrics.cs index e3fbfe01..d5e5e7be 100644 --- a/src/slskd/Core/Metrics.cs +++ b/src/slskd/Core/Metrics.cs @@ -1,29 +1,76 @@ -using System; -using System.Diagnostics; -using System.Threading.Tasks; -using Prometheus; +// +// Copyright (c) slskd Team. All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published +// by the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see https://www.gnu.org/licenses/. +// namespace slskd { + using System; + using System.Diagnostics; + using System.Threading.Tasks; + using Prometheus; + + /// + /// Application metrics. + /// public static class Metrics { - public static Histogram SearchResponseLatency { get; } = Prometheus.Metrics - .CreateHistogram($"slskd_search_response_latency", "The time taken to resolve a response to an incoming search request, in milliseconds", - new HistogramConfiguration - { - Buckets = Histogram.ExponentialBuckets(1, 2, 10), - }); + /// + /// Gets a histogram representing the time taken to resolve a response to an incoming search request, in milliseconds. + /// + public static Histogram SearchResponseLatency { get; } = Prometheus.Metrics.CreateHistogram( + "slskd_search_response_latency", + "The time taken to resolve a response to an incoming search request, in milliseconds", + new HistogramConfiguration + { + Buckets = Histogram.ExponentialBuckets(1, 2, 10), + }); + /// + /// Gets a counter representing the total number of search requests received. + /// public static Counter SearchRequestsReceived { get; } = Prometheus.Metrics.CreateCounter("slskd_search_requests_received", "Total number of search requests received"); + + /// + /// Gets a counter representing the total number of search responses sent. + /// public static Counter SearchResponsesSent { get; } = Prometheus.Metrics.CreateCounter("slskd_search_responses_sent", "Total number of search responses sent"); + /// + /// Gets a counter representing the total number of browse responses sent. + /// public static Counter BrowseResponsesSent { get; } = Prometheus.Metrics.CreateCounter("slskd_browse_responses_sent", "Total number of browse responses sent"); - public static Histogram BrowseResponseLatency { get; } = Prometheus.Metrics.CreateHistogram("slskd_browse_response_latency", "The time taken to resolve a response to an incoming browse request, in milliseconds", + + /// + /// Gets a histogram representing the the time taken to resolve a response to an incoming browse request, in milliseconds. + /// + public static Histogram BrowseResponseLatency { get; } = Prometheus.Metrics.CreateHistogram( + "slskd_browse_response_latency", + "The time taken to resolve a response to an incoming browse request, in milliseconds", new HistogramConfiguration { Buckets = Histogram.ExponentialBuckets(1, 2, 10), }); + /// + /// Measure the duration of the provided with the specified . + /// + /// + /// + /// + /// public static T Measure(Histogram histogram, Func action) { var sw = new Stopwatch(); @@ -38,6 +85,13 @@ namespace slskd return result; } + /// + /// Measure the duration of the provided with the specified . + /// + /// + /// + /// + /// public static async Task MeasureAsync(Histogram histogram, Func> action) { var sw = new Stopwatch(); -- cgit v1.2.3 From c2a3dd0a27b1a23e84cf537576f77d95dc69f2bf Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Fri, 26 Aug 2022 11:02:37 -0500 Subject: stratify metrics into classes, add dnet metrics --- src/slskd/Core/Metrics.cs | 100 +++++++++++++++++++++++++++++----------------- 1 file changed, 63 insertions(+), 37 deletions(-) (limited to 'src/slskd/Core') diff --git a/src/slskd/Core/Metrics.cs b/src/slskd/Core/Metrics.cs index d5e5e7be..0c31e514 100644 --- a/src/slskd/Core/Metrics.cs +++ b/src/slskd/Core/Metrics.cs @@ -22,47 +22,73 @@ namespace slskd using System.Threading.Tasks; using Prometheus; - /// - /// Application metrics. - /// public static class Metrics { - /// - /// Gets a histogram representing the time taken to resolve a response to an incoming search request, in milliseconds. - /// - public static Histogram SearchResponseLatency { get; } = Prometheus.Metrics.CreateHistogram( - "slskd_search_response_latency", - "The time taken to resolve a response to an incoming search request, in milliseconds", - new HistogramConfiguration - { - Buckets = Histogram.ExponentialBuckets(1, 2, 10), - }); - - /// - /// Gets a counter representing the total number of search requests received. - /// - public static Counter SearchRequestsReceived { get; } = Prometheus.Metrics.CreateCounter("slskd_search_requests_received", "Total number of search requests received"); - - /// - /// Gets a counter representing the total number of search responses sent. - /// - public static Counter SearchResponsesSent { get; } = Prometheus.Metrics.CreateCounter("slskd_search_responses_sent", "Total number of search responses sent"); + public static class Search + { + /// + /// Gets a histogram representing the time taken to resolve a response to an incoming search request, in milliseconds. + /// + public static Histogram ResponseLatency { get; } = Prometheus.Metrics.CreateHistogram( + "slskd_search_response_latency", + "The time taken to resolve a response to an incoming search request, in milliseconds", + new HistogramConfiguration + { + Buckets = Histogram.ExponentialBuckets(1, 2, 10), + }); + + /// + /// Gets a counter representing the total number of search requests received. + /// + public static Counter RequestsReceived { get; } = Prometheus.Metrics.CreateCounter("slskd_search_requests_received", "Total number of search requests received"); + + /// + /// Gets a counter representing the total number of search responses sent. + /// + public static Counter ResponsesSent { get; } = Prometheus.Metrics.CreateCounter("slskd_search_responses_sent", "Total number of search responses sent"); + } - /// - /// Gets a counter representing the total number of browse responses sent. - /// - public static Counter BrowseResponsesSent { get; } = Prometheus.Metrics.CreateCounter("slskd_browse_responses_sent", "Total number of browse responses sent"); + public static class Browse + { + /// + /// Gets a counter representing the total number of browse responses sent. + /// + public static Counter ResponsesSent { get; } = Prometheus.Metrics.CreateCounter("slskd_browse_responses_sent", "Total number of browse responses sent"); + + /// + /// Gets a histogram representing the time taken to resolve a response to an incoming browse request, in milliseconds. + /// + public static Histogram ResponseLatency { get; } = Prometheus.Metrics.CreateHistogram( + "slskd_browse_response_latency", + "The time taken to resolve a response to an incoming browse request, in milliseconds", + new HistogramConfiguration + { + Buckets = Histogram.ExponentialBuckets(1, 2, 10), + }); + } - /// - /// Gets a histogram representing the the time taken to resolve a response to an incoming browse request, in milliseconds. - /// - public static Histogram BrowseResponseLatency { get; } = Prometheus.Metrics.CreateHistogram( - "slskd_browse_response_latency", - "The time taken to resolve a response to an incoming browse request, in milliseconds", - new HistogramConfiguration - { - Buckets = Histogram.ExponentialBuckets(1, 2, 10), - }); + public static class DistributedNetwork + { + /// + /// Gets a gauge representing the current number of connected distributed children. + /// + public static Gauge Children { get; } = Prometheus.Metrics.CreateGauge("slskd_dnet_children", "Current number of connected distributed children"); + + /// + /// Gets a gauge representing the current distributed child limit. + /// + public static Gauge ChildLimit { get; } = Prometheus.Metrics.CreateGauge("slskd_dnet_child_limit", "Current distributed child limit"); + + /// + /// Gets a gauge indicating whether a distributed parent connection is established. + /// + public static Gauge HasParent { get; } = Prometheus.Metrics.CreateGauge("slskd_dnet_has_parent", "A value indicating whether a distributed parent connection is established"); + + /// + /// Gets a gauge representing the current distributed branch level. + /// + public static Gauge BranchLevel { get; } = Prometheus.Metrics.CreateGauge("slskd_dnet_branch_level", "Current distributed branch level"); + } /// /// Measure the duration of the provided with the specified . -- cgit v1.2.3 From 10840007e9d96483e747800969ebba38fa5eab6a Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 28 Aug 2022 00:34:07 -0500 Subject: add Clock --- src/slskd/Core/Clock.cs | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/slskd/Core/Clock.cs (limited to 'src/slskd/Core') diff --git a/src/slskd/Core/Clock.cs b/src/slskd/Core/Clock.cs new file mode 100644 index 00000000..4d2e6c10 --- /dev/null +++ b/src/slskd/Core/Clock.cs @@ -0,0 +1,40 @@ +// +// Copyright (c) slskd Team. All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published +// by the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see https://www.gnu.org/licenses/. +// + +namespace slskd +{ + using System; + using System.Timers; + + /// + /// The application clock, used for time based events. + /// + public static class Clock + { + static Clock() + { + EveryMinuteTimer.Elapsed += (_, _) => EveryMinute?.Invoke(null, EventArgs.Empty); + } + + /// + /// Fires every 60 seconds. + /// + public static event EventHandler EveryMinute; + + private static Timer EveryMinuteTimer { get; } = new Timer() { AutoReset = true, Interval = 60000, Enabled = true }; + } +} \ No newline at end of file -- cgit v1.2.3 From cedd5183a1973400d6d2b4a4b2c29ff18fcc1af0 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 28 Aug 2022 00:34:44 -0500 Subject: add more metrics. remove Measure() --- src/slskd/Core/Metrics.cs | 64 ++++++++++++++++------------------------------- 1 file changed, 21 insertions(+), 43 deletions(-) (limited to 'src/slskd/Core') diff --git a/src/slskd/Core/Metrics.cs b/src/slskd/Core/Metrics.cs index 0c31e514..d91920f6 100644 --- a/src/slskd/Core/Metrics.cs +++ b/src/slskd/Core/Metrics.cs @@ -17,9 +17,6 @@ namespace slskd { - using System; - using System.Diagnostics; - using System.Threading.Tasks; using Prometheus; public static class Metrics @@ -37,6 +34,11 @@ namespace slskd Buckets = Histogram.ExponentialBuckets(1, 2, 10), }); + /// + /// Gets an EMA representing the average time taken to resolve a response to an incoming search request, in milliseconds. + /// + public static ExponentialMovingAverage CurrentResponseLatency { get; } = new ExponentialMovingAverage(smoothingFactor: 0.5, onUpdate: value => CurrentResponseLatencyGauge.Set(value)); + /// /// Gets a counter representing the total number of search requests received. /// @@ -46,6 +48,8 @@ namespace slskd /// Gets a counter representing the total number of search responses sent. /// public static Counter ResponsesSent { get; } = Prometheus.Metrics.CreateCounter("slskd_search_responses_sent", "Total number of search responses sent"); + + private static Gauge CurrentResponseLatencyGauge { get; } = Prometheus.Metrics.CreateGauge("slskd_search_response_latency_current", "The average time taken to resolve a response to an incoming search request, in milliseconds"); } public static class Browse @@ -88,48 +92,22 @@ namespace slskd /// Gets a gauge representing the current distributed branch level. /// public static Gauge BranchLevel { get; } = Prometheus.Metrics.CreateGauge("slskd_dnet_branch_level", "Current distributed branch level"); - } - - /// - /// Measure the duration of the provided with the specified . - /// - /// - /// - /// - /// - public static T Measure(Histogram histogram, Func action) - { - var sw = new Stopwatch(); - sw.Start(); - - var result = action(); - - sw.Stop(); - - histogram.Observe(sw.ElapsedMilliseconds); - - return result; - } - /// - /// Measure the duration of the provided with the specified . - /// - /// - /// - /// - /// - public static async Task MeasureAsync(Histogram histogram, Func> action) - { - var sw = new Stopwatch(); - sw.Start(); - - var result = await action(); - - sw.Stop(); - - histogram.Observe(sw.ElapsedMilliseconds); + /// + /// Gets a gauge representing the most recent average time tekn to broadcast incoming search requests to connected children. + /// + public static Gauge CurrentBroadcastLatency { get; } = Prometheus.Metrics.CreateGauge("slskd_dnet_broadcast_latency_current", "The average time taken to broadcast incoming search requests to connected children"); - return result; + /// + /// Gets a histogram representing the time taken to resolve a response to an incoming browse request, in milliseconds. + /// + public static Histogram BroadcastLatency { get; } = Prometheus.Metrics.CreateHistogram( + "slskd_dnet_broadcast_latency", + "The time taken to broadcast incoming search requests to connected children, in milliseconds", + new HistogramConfiguration + { + Buckets = Histogram.ExponentialBuckets(0.5, 2, 12), + }); } } } -- cgit v1.2.3 From 47324cbcaabbff71d738ab97081513608aa02fde Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 28 Aug 2022 00:38:32 -0500 Subject: stub metrics controller --- .../Core/API/Controllers/MetricsController.cs | 54 ++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 src/slskd/Core/API/Controllers/MetricsController.cs (limited to 'src/slskd/Core') diff --git a/src/slskd/Core/API/Controllers/MetricsController.cs b/src/slskd/Core/API/Controllers/MetricsController.cs new file mode 100644 index 00000000..a4b9ecd8 --- /dev/null +++ b/src/slskd/Core/API/Controllers/MetricsController.cs @@ -0,0 +1,54 @@ +// +// Copyright (c) slskd Team. All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published +// by the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see https://www.gnu.org/licenses/. +// + +namespace slskd.Core.API +{ + using System.IO; + using System.Threading.Tasks; + using Microsoft.AspNetCore.Authorization; + using Microsoft.AspNetCore.Mvc; + + /// + /// Logs. + /// + [Route("api/v{version:apiVersion}/[controller]")] + [ApiVersion("0")] + [ApiController] + [Produces("application/json")] + [Consumes("application/json")] + public class MetricsController : ControllerBase + { + /// + /// Gets application metrics. + /// + /// + [HttpGet] + [Authorize] + public async Task Metrics() + { + using var stream = new MemoryStream(); + using var reader = new StreamReader(stream); + + await Prometheus.Metrics.DefaultRegistry.CollectAndExportAsTextAsync(stream); + stream.Position = 0; + + var response = await reader.ReadToEndAsync(); + + return Ok(response); + } + } +} -- cgit v1.2.3 From 97865d7952506ac59ad86916ae0595797502c188 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 28 Aug 2022 13:32:22 -0500 Subject: return metrics in plain text --- src/slskd/Core/API/Controllers/MetricsController.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/slskd/Core') diff --git a/src/slskd/Core/API/Controllers/MetricsController.cs b/src/slskd/Core/API/Controllers/MetricsController.cs index a4b9ecd8..aeccd97a 100644 --- a/src/slskd/Core/API/Controllers/MetricsController.cs +++ b/src/slskd/Core/API/Controllers/MetricsController.cs @@ -28,8 +28,8 @@ namespace slskd.Core.API [Route("api/v{version:apiVersion}/[controller]")] [ApiVersion("0")] [ApiController] - [Produces("application/json")] - [Consumes("application/json")] + [Produces("text/plain")] + [Consumes("text/plain")] public class MetricsController : ControllerBase { /// @@ -48,7 +48,7 @@ namespace slskd.Core.API var response = await reader.ReadToEndAsync(); - return Ok(response); + return Content(response, "text/plain"); } } } -- cgit v1.2.3 From 76f40ff5f2581da82fe710fb7f0fd15cd96bbdb3 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 28 Aug 2022 21:13:35 -0500 Subject: average browse response latency also --- src/slskd/Application.cs | 1 + src/slskd/Core/Metrics.cs | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) (limited to 'src/slskd/Core') 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 @@ -54,11 +54,6 @@ namespace slskd public static class Browse { - /// - /// Gets a counter representing the total number of browse responses sent. - /// - public static Counter ResponsesSent { get; } = Prometheus.Metrics.CreateCounter("slskd_browse_responses_sent", "Total number of browse responses sent"); - /// /// Gets a histogram representing the time taken to resolve a response to an incoming browse request, in milliseconds. /// @@ -69,6 +64,18 @@ namespace slskd { Buckets = Histogram.ExponentialBuckets(1, 2, 10), }); + + /// + /// Gets an EMA representing the average time taken to resolve a response to an incoming search request, in milliseconds. + /// + public static ExponentialMovingAverage CurrentResponseLatency { get; } = new ExponentialMovingAverage(smoothingFactor: 0.5, onUpdate: value => CurrentResponseLatencyGauge.Set(value)); + + /// + /// Gets a counter representing the total number of browse responses sent. + /// + 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 -- cgit v1.2.3 From a746ccab1a31c9e97a32abc707250d645618fa4c Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 28 Aug 2022 21:54:47 -0500 Subject: track browse requests --- src/slskd/Application.cs | 2 ++ src/slskd/Core/Metrics.cs | 5 +++++ 2 files changed, 7 insertions(+) (limited to 'src/slskd/Core') diff --git a/src/slskd/Application.cs b/src/slskd/Application.cs index bd34d612..04dbab2e 100644 --- a/src/slskd/Application.cs +++ b/src/slskd/Application.cs @@ -410,6 +410,8 @@ namespace slskd /// A Task resolving an IEnumerable of Soulseek.Directory. private async Task BrowseResponseResolver(string username, IPEndPoint endpoint) { + Metrics.Browse.RequestsReceived.Inc(1); + try { var sw = new Stopwatch(); diff --git a/src/slskd/Core/Metrics.cs b/src/slskd/Core/Metrics.cs index 98db91d2..83877500 100644 --- a/src/slskd/Core/Metrics.cs +++ b/src/slskd/Core/Metrics.cs @@ -70,6 +70,11 @@ namespace slskd /// public static ExponentialMovingAverage CurrentResponseLatency { get; } = new ExponentialMovingAverage(smoothingFactor: 0.5, onUpdate: value => CurrentResponseLatencyGauge.Set(value)); + /// + /// Gets a counter representing the total number of browse requests received. + /// + public static Counter RequestsReceived { get; } = Prometheus.Metrics.CreateCounter("slskd_browse_requests_received", "Total number of browse requests received"); + /// /// Gets a counter representing the total number of browse responses sent. /// -- cgit v1.2.3