From 7b754893dd0fdf775346c9a0a6ccd20399c50bea Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Thu, 18 Dec 2025 08:42:36 -0600 Subject: add enqueue metrics --- src/slskd/Telemetry/Metrics.cs | 58 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) (limited to 'src/slskd/Telemetry') diff --git a/src/slskd/Telemetry/Metrics.cs b/src/slskd/Telemetry/Metrics.cs index 7bc6fd25..33d2bc40 100644 --- a/src/slskd/Telemetry/Metrics.cs +++ b/src/slskd/Telemetry/Metrics.cs @@ -83,7 +83,7 @@ public static class Metrics "The time taken to resolve a response to an incoming browse request, in milliseconds", new HistogramConfiguration { - Buckets = Histogram.ExponentialBuckets(1, 2, 10), + Buckets = Histogram.ExponentialBuckets(start: 1, factor: 2, count: 10), }); /// @@ -104,6 +104,62 @@ public static class Metrics 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"); } + /// + /// Metrics related to incoming enqueue requests and responses. + /// + public static class Enqueue + { + /// + /// Gets a histogram representing the time taken to evaluate an incoming request to enqueue a file against configured limits, in milliseconds. + /// + public static Histogram DecisionLatency { get; } = Prometheus.Metrics.CreateHistogram( + "slskd_enqueue_decision_latency", + "The time taken to evaluate an incoming request to enqueue a file against configured limits, in milliseconds", + new HistogramConfiguration + { + Buckets = Histogram.ExponentialBuckets(start: 1, factor: 2, count: 16), // up to ~2 seconds + }); + + /// + /// Gets an EMA representing the average time taken to evaluate an incoming request to enqueue a file against configured limits, in milliseconds. + /// + public static ExponentialMovingAverage CurrentDecisionLatency { get; } = new ExponentialMovingAverage(smoothingFactor: 0.5, onUpdate: value => CurrentDecisionLatencyGauge.Set(value)); + + /// + /// Gets a histogram representing the total time taken to resolve a response to an incoming request to enqueue a file, in milliseconds. + /// + public static Histogram ResponseLatency { get; } = Prometheus.Metrics.CreateHistogram( + "slskd_enqueue_response_latency", + "The total time taken to resolve a response to an incoming request to enqueue a file, in milliseconds", + new HistogramConfiguration + { + Buckets = Histogram.ExponentialBuckets(start: 1, factor: 2, count: 16), // up to ~2 seconds + }); + + /// + /// Gets an EMA representing the average total time taken to resolve a response to an incoming request to enqueue a file, 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 incoming enqueue requests received. + /// + public static Counter RequestsReceived { get; } = Prometheus.Metrics.CreateCounter("slskd_enqueue_requests_received", "Total number of incoming enqueue requests received"); + + /// + /// Gets a counter representing the total number of incoming enqueue requests accepted. + /// + public static Counter RequestsAccepted { get; } = Prometheus.Metrics.CreateCounter("slskd_enqueue_requests_accepted", "Total number of incoming enqueue requests accepted"); + + /// + /// Gets a gauge representing the number of incoming enqueue requests waiting to be processed. + /// + public static Gauge CurrentRequestQueueDepth { get; } = Prometheus.Metrics.CreateGauge("slskd_enqueue_request_queue_depth_current", "The number of incoming enqueue requests waiting to be processed"); + + private static Gauge CurrentDecisionLatencyGauge { get; } = Prometheus.Metrics.CreateGauge("slskd_enqueue_decision_latency_current", "The average time taken to evaluate an incoming request to enqueue a file against configured limits, in milliseconds"); + private static Gauge CurrentResponseLatencyGauge { get; } = Prometheus.Metrics.CreateGauge("slskd_enqueue_response_latency_current", "The average total time taken to resolve a response to an incoming request to enqueue a file, in milliseconds"); + } + /// /// Metrics related to the distributed network. /// -- cgit v1.2.3 From 3e04ab2c3c81ebee11178c1767d70476bfa3575f Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Thu, 1 Jan 2026 18:10:40 -0600 Subject: add counters for dropped and rejected requests, rename latency --- src/slskd/Telemetry/Metrics.cs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'src/slskd/Telemetry') diff --git a/src/slskd/Telemetry/Metrics.cs b/src/slskd/Telemetry/Metrics.cs index 33d2bc40..610ab9c6 100644 --- a/src/slskd/Telemetry/Metrics.cs +++ b/src/slskd/Telemetry/Metrics.cs @@ -128,8 +128,8 @@ public static class Metrics /// /// Gets a histogram representing the total time taken to resolve a response to an incoming request to enqueue a file, in milliseconds. /// - public static Histogram ResponseLatency { get; } = Prometheus.Metrics.CreateHistogram( - "slskd_enqueue_response_latency", + public static Histogram Latency { get; } = Prometheus.Metrics.CreateHistogram( + "slskd_enqueue_latency", "The total time taken to resolve a response to an incoming request to enqueue a file, in milliseconds", new HistogramConfiguration { @@ -139,13 +139,23 @@ public static class Metrics /// /// Gets an EMA representing the average total time taken to resolve a response to an incoming request to enqueue a file, in milliseconds. /// - public static ExponentialMovingAverage CurrentResponseLatency { get; } = new ExponentialMovingAverage(smoothingFactor: 0.5, onUpdate: value => CurrentResponseLatencyGauge.Set(value)); + public static ExponentialMovingAverage CurrentLatency { get; } = new ExponentialMovingAverage(smoothingFactor: 0.5, onUpdate: value => CurrentResponseLatencyGauge.Set(value)); /// /// Gets a counter representing the total number of incoming enqueue requests received. /// public static Counter RequestsReceived { get; } = Prometheus.Metrics.CreateCounter("slskd_enqueue_requests_received", "Total number of incoming enqueue requests received"); + /// + /// Gets a counter representing the total number of incoming enqueue requests dropped due to processing pressure. + /// + public static Counter RequestsDropped { get; } = Prometheus.Metrics.CreateCounter("slskd_enqueue_requests_dropped", "Total number of incoming enqueue requests dropped due to processing pressure"); + + /// + /// Gets a counter representing the total number of incoming enqueue requests rejected. + /// + public static Counter RequestsRejected { get; } = Prometheus.Metrics.CreateCounter("slskd_enqueue_requests_rejected", "Total number of incoming enqueue requests rejected"); + /// /// Gets a counter representing the total number of incoming enqueue requests accepted. /// @@ -154,10 +164,10 @@ public static class Metrics /// /// Gets a gauge representing the number of incoming enqueue requests waiting to be processed. /// - public static Gauge CurrentRequestQueueDepth { get; } = Prometheus.Metrics.CreateGauge("slskd_enqueue_request_queue_depth_current", "The number of incoming enqueue requests waiting to be processed"); + public static Gauge CurrentQueueDepth { get; } = Prometheus.Metrics.CreateGauge("slskd_enqueue_queue_depth_current", "The number of incoming enqueue requests waiting to be processed"); private static Gauge CurrentDecisionLatencyGauge { get; } = Prometheus.Metrics.CreateGauge("slskd_enqueue_decision_latency_current", "The average time taken to evaluate an incoming request to enqueue a file against configured limits, in milliseconds"); - private static Gauge CurrentResponseLatencyGauge { get; } = Prometheus.Metrics.CreateGauge("slskd_enqueue_response_latency_current", "The average total time taken to resolve a response to an incoming request to enqueue a file, in milliseconds"); + private static Gauge CurrentLatencyGauge { get; } = Prometheus.Metrics.CreateGauge("slskd_enqueue_latency_current", "The average total time taken to resolve a response to an incoming request to enqueue a file, in milliseconds"); } /// -- cgit v1.2.3 From 870324657b842412a9af8268c65fac3ff56aa278 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Thu, 1 Jan 2026 18:26:07 -0600 Subject: oops --- src/slskd/Telemetry/Metrics.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/slskd/Telemetry') diff --git a/src/slskd/Telemetry/Metrics.cs b/src/slskd/Telemetry/Metrics.cs index 610ab9c6..33550577 100644 --- a/src/slskd/Telemetry/Metrics.cs +++ b/src/slskd/Telemetry/Metrics.cs @@ -139,7 +139,7 @@ public static class Metrics /// /// Gets an EMA representing the average total time taken to resolve a response to an incoming request to enqueue a file, in milliseconds. /// - public static ExponentialMovingAverage CurrentLatency { get; } = new ExponentialMovingAverage(smoothingFactor: 0.5, onUpdate: value => CurrentResponseLatencyGauge.Set(value)); + public static ExponentialMovingAverage CurrentLatency { get; } = new ExponentialMovingAverage(smoothingFactor: 0.5, onUpdate: value => CurrentLatencyGauge.Set(value)); /// /// Gets a counter representing the total number of incoming enqueue requests received. -- cgit v1.2.3