From 4d2089daa0b410120541c0927a69447206466e29 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sat, 2 May 2026 16:58:37 -0500 Subject: fix up download metrics too --- src/slskd/Telemetry/Metrics.cs | 76 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 67 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/slskd/Telemetry/Metrics.cs b/src/slskd/Telemetry/Metrics.cs index dae87699..b7ee0092 100644 --- a/src/slskd/Telemetry/Metrics.cs +++ b/src/slskd/Telemetry/Metrics.cs @@ -356,13 +356,6 @@ public static class Metrics name: "slskd_transfers_uploads_completed_succeeded", help: "Total number of uploads that completed successfully"); - /// - /// Gets a counter representing the total number of uploads that failed. - /// - public static Counter Failed { get; } = Prometheus.Metrics.CreateCounter( - name: "slskd_transfers_uploads_completed_failed", - help: "Total number of uploads that failed"); - /// /// Gets a counter representing the total number of bytes transferred by successfully completed uploads. /// @@ -370,6 +363,13 @@ public static class Metrics name: "slskd_transfers_uploads_completed_bytes", help: "Total number of bytes transferred by successfully completed uploads"); + /// + /// Gets a counter representing the total number of uploads that failed. + /// + public static Counter Failed { get; } = Prometheus.Metrics.CreateCounter( + name: "slskd_transfers_uploads_completed_failed", + help: "Total number of uploads that failed"); + /// /// Gets a histogram representing the the average speed of completed uploads, in bytes per second. /// @@ -437,7 +437,7 @@ public static class Metrics /// /// 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 ExponentialMovingAverage CurrentTotalSpeed { get; } = new ExponentialMovingAverage(smoothingFactor: 0.5, onUpdate: value => CurrentTotalSpeedGauge.Set(value)); 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"); @@ -445,7 +445,7 @@ public static class Metrics /// /// 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 ExponentialMovingAverage CurrentAverageSpeed { 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"); @@ -477,6 +477,64 @@ public static class Metrics name: "slskd_transfers_downloads_queued_bytes_current", help: "Current total size, in bytes, of queued downloads"); } + + /// + /// Metrics related to completed downloads. + /// + public static class Completed + { + /// + /// Gets a counter representing the total number of downloads that completed successfully. + /// + public static Counter Succeeded { get; } = Prometheus.Metrics.CreateCounter( + name: "slskd_transfers_downloads_completed_succeeded", + help: "Total number of downloads that completed successfully"); + + /// + /// Gets a counter representing the total number of bytes transferred by successfully completed downloads. + /// + public static Counter Bytes { get; } = Prometheus.Metrics.CreateCounter( + name: "slskd_transfers_downloads_completed_bytes", + help: "Total number of bytes transferred by successfully completed downloads"); + + /// + /// Gets a counter representing the total number of downloads that failed. + /// + public static Counter Failed { get; } = Prometheus.Metrics.CreateCounter( + name: "slskd_transfers_downloads_completed_failed", + help: "Total number of downloads that failed"); + + /// + /// Gets a histogram representing the the average speed of completed downloads, in bytes per second. + /// + public static Histogram AverageSpeed { get; } = Prometheus.Metrics.CreateHistogram( + name: "slskd_transfers_downloads_completed_speed_average", + help: "The average speed of completed downloads, in bytes per second", + new HistogramConfiguration + { + Buckets = [ + 1_024, // 1 KB/s + 10_240, // 10 KB/s + 51_200, // 50 KB/s + 102_400, // 100 KB/s + 204_800, // 200 KB/s + 307_200, // 300 KB/s + 409_600, // 400 KB/s + 512_000, // 500 KB/s + 1_048_576, // 1 MB/s + 2_097_152, // 2 MB/s + 4_194_304, // 4 MB/s + 6_291_456, // 6 MB/s + 10_485_760, // 10 MB/s + 26_214_400, // 25 MB/s + 52_428_800, // 50 MB/s + 104_857_600, // 100 MB/s + 262_144_000, // 250 MB/s + 524_288_000, // 500 MB/s + 1_073_741_824, // 1 GB/s + ], + }); + } } } -- cgit v1.2.3