diff --git a/Jellyfin.Server/Jellyfin.Server.csproj b/Jellyfin.Server/Jellyfin.Server.csproj
index 270cdeaaf..c49fc41f4 100644
--- a/Jellyfin.Server/Jellyfin.Server.csproj
+++ b/Jellyfin.Server/Jellyfin.Server.csproj
@@ -43,6 +43,9 @@
+
+
+
diff --git a/Jellyfin.Server/Program.cs b/Jellyfin.Server/Program.cs
index 193d30e3a..be070f9d5 100644
--- a/Jellyfin.Server/Program.cs
+++ b/Jellyfin.Server/Program.cs
@@ -28,6 +28,7 @@ using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
+using Prometheus.DotNetRuntime;
using Serilog;
using Serilog.Extensions.Logging;
using SQLitePCL;
@@ -161,6 +162,9 @@ namespace Jellyfin.Server
ApplicationHost.LogEnvironmentInfo(_logger, appPaths);
+ // Initialize runtime stat collection
+ IDisposable collector = DotNetRuntimeStatsBuilder.Default().StartCollecting();
+
// Make sure we have all the code pages we can get
// Ref: https://docs.microsoft.com/en-us/dotnet/api/system.text.codepagesencodingprovider.instance?view=netcore-3.0#remarks
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
diff --git a/Jellyfin.Server/Startup.cs b/Jellyfin.Server/Startup.cs
index 4d7d56e9d..2e5f843e3 100644
--- a/Jellyfin.Server/Startup.cs
+++ b/Jellyfin.Server/Startup.cs
@@ -5,6 +5,7 @@ using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
+using Prometheus;
namespace Jellyfin.Server
{
@@ -69,9 +70,11 @@ namespace Jellyfin.Server
app.UseJellyfinApiSwagger();
app.UseRouting();
app.UseAuthorization();
+ app.UseHttpMetrics(); // Must be registered after any middleware that could chagne HTTP response codes or the data will be bad
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
+ endpoints.MapMetrics();
});
app.Use(serverApplicationHost.ExecuteHttpHandlerAsync);