aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/slskd/Core/Metrics.cs17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/slskd/Core/Metrics.cs b/src/slskd/Core/Metrics.cs
index 83877500..3fc9a9b1 100644
--- a/src/slskd/Core/Metrics.cs
+++ b/src/slskd/Core/Metrics.cs
@@ -17,10 +17,27 @@
namespace slskd
{
+ using System.IO;
+ using System.Threading.Tasks;
using Prometheus;
public static class Metrics
{
+ /// <summary>
+ /// Builds metrics into a Prometheus-formatted string.
+ /// </summary>
+ /// <returns>A Prometheus-formatted string.</returns>
+ public static async Task<string> BuildAsync()
+ {
+ using var stream = new MemoryStream();
+ using var reader = new StreamReader(stream);
+
+ await Prometheus.Metrics.DefaultRegistry.CollectAndExportAsTextAsync(stream);
+ stream.Position = 0;
+
+ return await reader.ReadToEndAsync();
+ }
+
public static class Search
{
/// <summary>