From 070360caf52cfefd0e4a2609ef98a0e2183248c1 Mon Sep 17 00:00:00 2001
From: karashiiro <49822414+karashiiro@users.noreply.github.com>
Date: Tue, 17 Jun 2025 19:25:51 -0700
Subject: [PATCH] Add Prometheus exporter
---
.../Prima.Application.csproj | 2 ++
src/Prima.Application/Program.cs | 20 +++++++++++++++++++
src/Prima/Prima.csproj | 1 +
3 files changed, 23 insertions(+)
diff --git a/src/Prima.Application/Prima.Application.csproj b/src/Prima.Application/Prima.Application.csproj
index bf8ae34..63dc027 100644
--- a/src/Prima.Application/Prima.Application.csproj
+++ b/src/Prima.Application/Prima.Application.csproj
@@ -23,6 +23,8 @@
+
+
diff --git a/src/Prima.Application/Program.cs b/src/Prima.Application/Program.cs
index e120fc9..44503f4 100644
--- a/src/Prima.Application/Program.cs
+++ b/src/Prima.Application/Program.cs
@@ -27,6 +27,8 @@
using Prima.Game.FFXIV.FFLogs.Rules;
using Prima.Game.FFXIV.XIVAPI;
using Prima.Services;
+using Prometheus;
+using Prometheus.DotNetRuntime;
using Quartz;
var googleApiSecretPath = Environment.GetEnvironmentVariable("PRIMA_GOOGLE_SECRET") ??
@@ -48,6 +50,24 @@
var host = Host.CreateDefaultBuilder()
.ConfigureServices((_, sc) =>
{
+ var metricsServer = new MetricServer(3000);
+ try
+ {
+ metricsServer.Start();
+ }
+ catch (HttpListenerException ex)
+ {
+ // ReSharper disable LocalizableElement
+ Console.WriteLine($"Failed to start metric server: {ex.Message}");
+ Console.WriteLine("You may need to grant permissions to your user account if not running as Administrator:");
+ Console.WriteLine("netsh http add urlacl url=http://+:1234/metrics user=DOMAIN\\user");
+ // ReSharper restore LocalizableElement
+ return;
+ }
+
+ sc.AddSingleton(metricsServer);
+ sc.AddSingleton(DotNetRuntimeStatsBuilder.Default().StartCollecting());
+
var disConfig = new DiscordSocketConfig
{
AlwaysDownloadUsers = true,
diff --git a/src/Prima/Prima.csproj b/src/Prima/Prima.csproj
index 176f000..a28b2c7 100644
--- a/src/Prima/Prima.csproj
+++ b/src/Prima/Prima.csproj
@@ -37,6 +37,7 @@
+