diff options
| author | JP Dillingham <jp@dillingham.me> | 2026-05-01 18:54:48 -0500 |
|---|---|---|
| committer | JP Dillingham <jp@dillingham.me> | 2026-05-01 18:54:48 -0500 |
| commit | 477eaa97466cd36280639b1a43fa95938d4e99a2 (patch) | |
| tree | f5f3e6039b92b50e472e9c01be53611104401f41 /src | |
| parent | 5895c77c09efd92499ffb0ff9d492f46c4e05c16 (diff) | |
| download | slskd-477eaa97466cd36280639b1a43fa95938d4e99a2.tar.gz | |
add downloads
Diffstat (limited to 'src')
| -rw-r--r-- | src/slskd/Telemetry/Metrics.cs | 76 |
1 files changed, 76 insertions, 0 deletions
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"); } } + + /// <summary> + /// Metrics related to downloads. + /// </summary> + public static class Downloads + { + /// <summary> + /// Metrics related to in-progress downloads. + /// </summary> + public static class InProgress + { + /// <summary> + /// Gets a gauge representing the current number of unique users with in-progress downloads. + /// </summary> + 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"); + + /// <summary> + /// Gets a gauge representing the current number of in-progress downloads. + /// </summary> + public static Gauge Files { get; } = Prometheus.Metrics.CreateGauge( + name: "slskd_transfers_downloads_in_progress_files_current", + help: "Current number of in-progress downloads"); + + /// <summary> + /// Gets a gauge representing the current total size, in bytes, of in-progress downloads. + /// </summary> + 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"); + + /// <summary> + /// Gets a gauge representing the current total speed, in bytes per second, of in-progress downloads. + /// </summary> + 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"); + + /// <summary> + /// Gets a gauge representing the current average speed, in bytes per second, of in-progress downloads. + /// </summary> + 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"); + } + + /// <summary> + /// Metrics related to queued downloads. + /// </summary> + public static class Queued + { + /// <summary> + /// Gets a gauge representing the current number of unique users with queued downloads. + /// </summary> + public static Gauge Users { get; } = Prometheus.Metrics.CreateGauge( + name: "slskd_transfers_downloads_queued_users_current", + help: "Current number of unique users with queued downloads"); + + /// <summary> + /// Gets a gauge representing the current number of queued downloads. + /// </summary> + public static Gauge Files { get; } = Prometheus.Metrics.CreateGauge( + name: "slskd_transfers_downloads_queued_files_current", + help: "Current number of queued downloads"); + + /// <summary> + /// Gets a gauge representing the current total size, in bytes, of queued downloads. + /// </summary> + public static Gauge Bytes { get; } = Prometheus.Metrics.CreateGauge( + name: "slskd_transfers_downloads_queued_bytes_current", + help: "Current total size, in bytes, of queued downloads"); + } + } } /// <summary> |
