From c2a3dd0a27b1a23e84cf537576f77d95dc69f2bf Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Fri, 26 Aug 2022 11:02:37 -0500 Subject: stratify metrics into classes, add dnet metrics --- src/slskd/Core/Metrics.cs | 100 +++++++++++++++++++++++++++++----------------- 1 file changed, 63 insertions(+), 37 deletions(-) (limited to 'src') diff --git a/src/slskd/Core/Metrics.cs b/src/slskd/Core/Metrics.cs index d5e5e7be..0c31e514 100644 --- a/src/slskd/Core/Metrics.cs +++ b/src/slskd/Core/Metrics.cs @@ -22,47 +22,73 @@ namespace slskd using System.Threading.Tasks; using Prometheus; - /// - /// Application metrics. - /// public static class Metrics { - /// - /// Gets a histogram representing the time taken to resolve a response to an incoming search request, in milliseconds. - /// - public static Histogram SearchResponseLatency { get; } = Prometheus.Metrics.CreateHistogram( - "slskd_search_response_latency", - "The time taken to resolve a response to an incoming search request, in milliseconds", - new HistogramConfiguration - { - Buckets = Histogram.ExponentialBuckets(1, 2, 10), - }); - - /// - /// Gets a counter representing the total number of search requests received. - /// - public static Counter SearchRequestsReceived { get; } = Prometheus.Metrics.CreateCounter("slskd_search_requests_received", "Total number of search requests received"); - - /// - /// Gets a counter representing the total number of search responses sent. - /// - public static Counter SearchResponsesSent { get; } = Prometheus.Metrics.CreateCounter("slskd_search_responses_sent", "Total number of search responses sent"); + public static class Search + { + /// + /// Gets a histogram representing the time taken to resolve a response to an incoming search request, in milliseconds. + /// + public static Histogram ResponseLatency { get; } = Prometheus.Metrics.CreateHistogram( + "slskd_search_response_latency", + "The time taken to resolve a response to an incoming search request, in milliseconds", + new HistogramConfiguration + { + Buckets = Histogram.ExponentialBuckets(1, 2, 10), + }); + + /// + /// Gets a counter representing the total number of search requests received. + /// + public static Counter RequestsReceived { get; } = Prometheus.Metrics.CreateCounter("slskd_search_requests_received", "Total number of search requests received"); + + /// + /// Gets a counter representing the total number of search responses sent. + /// + public static Counter ResponsesSent { get; } = Prometheus.Metrics.CreateCounter("slskd_search_responses_sent", "Total number of search responses sent"); + } - /// - /// Gets a counter representing the total number of browse responses sent. - /// - public static Counter BrowseResponsesSent { get; } = Prometheus.Metrics.CreateCounter("slskd_browse_responses_sent", "Total number of browse responses sent"); + public static class Browse + { + /// + /// Gets a counter representing the total number of browse responses sent. + /// + public static Counter ResponsesSent { get; } = Prometheus.Metrics.CreateCounter("slskd_browse_responses_sent", "Total number of browse responses sent"); + + /// + /// Gets a histogram representing the time taken to resolve a response to an incoming browse request, in milliseconds. + /// + public static Histogram ResponseLatency { get; } = Prometheus.Metrics.CreateHistogram( + "slskd_browse_response_latency", + "The time taken to resolve a response to an incoming browse request, in milliseconds", + new HistogramConfiguration + { + Buckets = Histogram.ExponentialBuckets(1, 2, 10), + }); + } - /// - /// Gets a histogram representing the the time taken to resolve a response to an incoming browse request, in milliseconds. - /// - public static Histogram BrowseResponseLatency { get; } = Prometheus.Metrics.CreateHistogram( - "slskd_browse_response_latency", - "The time taken to resolve a response to an incoming browse request, in milliseconds", - new HistogramConfiguration - { - Buckets = Histogram.ExponentialBuckets(1, 2, 10), - }); + public static class DistributedNetwork + { + /// + /// Gets a gauge representing the current number of connected distributed children. + /// + public static Gauge Children { get; } = Prometheus.Metrics.CreateGauge("slskd_dnet_children", "Current number of connected distributed children"); + + /// + /// Gets a gauge representing the current distributed child limit. + /// + public static Gauge ChildLimit { get; } = Prometheus.Metrics.CreateGauge("slskd_dnet_child_limit", "Current distributed child limit"); + + /// + /// Gets a gauge indicating whether a distributed parent connection is established. + /// + public static Gauge HasParent { get; } = Prometheus.Metrics.CreateGauge("slskd_dnet_has_parent", "A value indicating whether a distributed parent connection is established"); + + /// + /// Gets a gauge representing the current distributed branch level. + /// + public static Gauge BranchLevel { get; } = Prometheus.Metrics.CreateGauge("slskd_dnet_branch_level", "Current distributed branch level"); + } /// /// Measure the duration of the provided with the specified . -- cgit v1.2.3