diff --git a/src/FakeRelay.Web/Controllers/ApiController.cs b/src/FakeRelay.Web/Controllers/ApiController.cs index ea5c374..1bf6844 100644 --- a/src/FakeRelay.Web/Controllers/ApiController.cs +++ b/src/FakeRelay.Web/Controllers/ApiController.cs @@ -2,12 +2,15 @@ using System.Collections.Immutable; using FakeRelay.Core.Helpers; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Caching.Memory; +using Prometheus; namespace FakeRelay.Web.Controllers; public class ApiController : Controller { private readonly IMemoryCache _memoryCache; + private static readonly Counter IndexRequests = + Metrics.CreateCounter("index_requests", "Requests to index statuses", "instance"); public ApiController(IMemoryCache memoryCache) { @@ -46,6 +49,7 @@ public class ApiController : Controller } var response = await MastodonHelper.EnqueueStatusToFetchAsync(host, statusUrl); + IndexRequests.WithLabels(host).Inc(); Response.Headers["instance"] = host; return Content(response, "application/activity+json"); } diff --git a/src/FakeRelay.Web/FakeRelay.Web.csproj b/src/FakeRelay.Web/FakeRelay.Web.csproj index a3cf4d0..82f8670 100644 --- a/src/FakeRelay.Web/FakeRelay.Web.csproj +++ b/src/FakeRelay.Web/FakeRelay.Web.csproj @@ -4,6 +4,10 @@ + + + + net6.0 enable diff --git a/src/FakeRelay.Web/Program.cs b/src/FakeRelay.Web/Program.cs index 2b8ba54..00a83d2 100644 --- a/src/FakeRelay.Web/Program.cs +++ b/src/FakeRelay.Web/Program.cs @@ -1,6 +1,7 @@ using FakeRelay.Core; using FakeRelay.Web.Services; using Microsoft.AspNetCore.HttpOverrides; +using Prometheus; var webApplicationOptions = new WebApplicationOptions { @@ -48,4 +49,9 @@ app.MapControllerRoute( "default", "{controller=Home}/{action=Index}/{id?}"); +app.UseEndpoints(endpoints => +{ + endpoints.MapMetrics(); +}); + app.Run();