forked from extern/FakeRelay
Add some metrics (more to come)
This commit is contained in:
parent
98b22a8ade
commit
2f587072ce
@ -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");
|
||||
}
|
||||
|
@ -4,6 +4,10 @@
|
||||
<ProjectReference Include="..\FakeRelay.Core\FakeRelay.Core.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="prometheus-net.AspNetCore" Version="7.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user