From 477eaa97466cd36280639b1a43fa95938d4e99a2 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Fri, 1 May 2026 18:54:48 -0500 Subject: add downloads --- src/slskd/Telemetry/Metrics.cs | 76 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) (limited to 'src') diff --git a/src/slskd/Telemetry/Metrics.cs b/src/slskd/Telemetry/Metrics.cs index 0ec86a94..0f998428 100644 --- a/src/slskd/Telemetry/Metrics.cs +++ b/src/slskd/Telemetry/Metrics.cs @@ -344,6 +344,82 @@ public static class Metrics help: "Current total size, in bytes, of queued uploads"); } } + + /// + /// Metrics related to downloads. + /// + public static class Downloads + { + /// + /// Metrics related to in-progress downloads. + /// + public static class InProgress + { + /// + /// Gets a gauge representing the current number of unique users with in-progress downloads. + /// + public static Gauge Users { get; } = Prometheus.Metrics.CreateGauge( + name: "slskd_transfers_downloads_in_progress_users_current", + help: "Current number of unique users with in-progress downloads"); + + /// + /// Gets a gauge representing the current number of in-progress downloads. + /// + public static Gauge Files { get; } = Prometheus.Metrics.CreateGauge( + name: "slskd_transfers_downloads_in_progress_files_current", + help: "Current number of in-progress downloads"); + + /// + /// Gets a gauge representing the current total size, in bytes, of in-progress downloads. + /// + public static Gauge Bytes { get; } = Prometheus.Metrics.CreateGauge( + name: "slskd_transfers_downloads_in_progress_bytes_current", + help: "Current total size, in bytes, of in-progress downloads"); + + /// + /// Gets a gauge representing the current total speed, in bytes per second, of in-progress downloads. + /// + public static TimedCounter TotalSpeed { get; } = new TimedCounter(TimeSpan.FromSeconds(1), onElapsed: count => CurrentTotalSpeedGauge.Set(count)); + public static Gauge CurrentTotalSpeedGauge { get; } = Prometheus.Metrics.CreateGauge( + name: "slskd_transfers_downloads_in_progress_speed_total_current", + help: "Current total speed, in bytes per second, of in-progress downloads"); + + /// + /// Gets a gauge representing the current average speed, in bytes per second, of in-progress downloads. + /// + public static ExponentialMovingAverage AverageSpeed { get; } = new ExponentialMovingAverage(smoothingFactor: 0.5, onUpdate: value => CurrentAverageSpeedGauge.Set(value)); + public static Gauge CurrentAverageSpeedGauge { get; } = Prometheus.Metrics.CreateGauge( + name: "slskd_transfers_downloads_in_progress_speed_average_current", + help: "Current average speed, in bytes per second, of in-progress downloads"); + } + + /// + /// Metrics related to queued downloads. + /// + public static class Queued + { + /// + /// Gets a gauge representing the current number of unique users with queued downloads. + /// + public static Gauge Users { get; } = Prometheus.Metrics.CreateGauge( + name: "slskd_transfers_downloads_queued_users_current", + help: "Current number of unique users with queued downloads"); + + /// + /// Gets a gauge representing the current number of queued downloads. + /// + public static Gauge Files { get; } = Prometheus.Metrics.CreateGauge( + name: "slskd_transfers_downloads_queued_files_current", + help: "Current number of queued downloads"); + + /// + /// Gets a gauge representing the current total size, in bytes, of queued downloads. + /// + public static Gauge Bytes { get; } = Prometheus.Metrics.CreateGauge( + name: "slskd_transfers_downloads_queued_bytes_current", + help: "Current total size, in bytes, of queued downloads"); + } + } } /// -- cgit v1.2.3