diff options
| author | JP Dillingham <jp@dillingham.me> | 2026-01-11 16:37:02 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-01-11 16:37:02 -0600 |
| commit | 358a6b1912681d656ff3ff569ddc5bf1bb6a6ef7 (patch) | |
| tree | ae86b9040faf8771c13b50406392dafbe50c506a /src/slskd/Telemetry | |
| parent | 8849d78cbe7057dacad9c00c471691af8e367cd9 (diff) | |
| parent | 0f2df52cbfe2b8afd517a598cbaf9fc55c36083c (diff) | |
| download | slskd-358a6b1912681d656ff3ff569ddc5bf1bb6a6ef7.tar.gz | |
Merge branch 'master' into paths
Diffstat (limited to 'src/slskd/Telemetry')
| -rw-r--r-- | src/slskd/Telemetry/Metrics.cs | 68 |
1 files changed, 67 insertions, 1 deletions
diff --git a/src/slskd/Telemetry/Metrics.cs b/src/slskd/Telemetry/Metrics.cs index 7bc6fd25..33550577 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), }); /// <summary> @@ -105,6 +105,72 @@ public static class Metrics } /// <summary> + /// Metrics related to incoming enqueue requests and responses. + /// </summary> + public static class Enqueue + { + /// <summary> + /// Gets a histogram representing the time taken to evaluate an incoming request to enqueue a file against configured limits, in milliseconds. + /// </summary> + 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 + }); + + /// <summary> + /// Gets an EMA representing the average time taken to evaluate an incoming request to enqueue a file against configured limits, in milliseconds. + /// </summary> + public static ExponentialMovingAverage CurrentDecisionLatency { get; } = new ExponentialMovingAverage(smoothingFactor: 0.5, onUpdate: value => CurrentDecisionLatencyGauge.Set(value)); + + /// <summary> + /// Gets a histogram representing the total time taken to resolve a response to an incoming request to enqueue a file, in milliseconds. + /// </summary> + 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 + { + Buckets = Histogram.ExponentialBuckets(start: 1, factor: 2, count: 16), // up to ~2 seconds + }); + + /// <summary> + /// Gets an EMA representing the average total time taken to resolve a response to an incoming request to enqueue a file, in milliseconds. + /// </summary> + public static ExponentialMovingAverage CurrentLatency { get; } = new ExponentialMovingAverage(smoothingFactor: 0.5, onUpdate: value => CurrentLatencyGauge.Set(value)); + + /// <summary> + /// Gets a counter representing the total number of incoming enqueue requests received. + /// </summary> + public static Counter RequestsReceived { get; } = Prometheus.Metrics.CreateCounter("slskd_enqueue_requests_received", "Total number of incoming enqueue requests received"); + + /// <summary> + /// Gets a counter representing the total number of incoming enqueue requests dropped due to processing pressure. + /// </summary> + public static Counter RequestsDropped { get; } = Prometheus.Metrics.CreateCounter("slskd_enqueue_requests_dropped", "Total number of incoming enqueue requests dropped due to processing pressure"); + + /// <summary> + /// Gets a counter representing the total number of incoming enqueue requests rejected. + /// </summary> + public static Counter RequestsRejected { get; } = Prometheus.Metrics.CreateCounter("slskd_enqueue_requests_rejected", "Total number of incoming enqueue requests rejected"); + + /// <summary> + /// Gets a counter representing the total number of incoming enqueue requests accepted. + /// </summary> + public static Counter RequestsAccepted { get; } = Prometheus.Metrics.CreateCounter("slskd_enqueue_requests_accepted", "Total number of incoming enqueue requests accepted"); + + /// <summary> + /// Gets a gauge representing the number of incoming enqueue requests waiting to be processed. + /// </summary> + 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 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"); + } + + /// <summary> /// Metrics related to the distributed network. /// </summary> public static class DistributedNetwork |
