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 FakeRelay.Core.Helpers;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.Extensions.Caching.Memory;
|
using Microsoft.Extensions.Caching.Memory;
|
||||||
|
using Prometheus;
|
||||||
|
|
||||||
namespace FakeRelay.Web.Controllers;
|
namespace FakeRelay.Web.Controllers;
|
||||||
|
|
||||||
public class ApiController : Controller
|
public class ApiController : Controller
|
||||||
{
|
{
|
||||||
private readonly IMemoryCache _memoryCache;
|
private readonly IMemoryCache _memoryCache;
|
||||||
|
private static readonly Counter IndexRequests =
|
||||||
|
Metrics.CreateCounter("index_requests", "Requests to index statuses", "instance");
|
||||||
|
|
||||||
public ApiController(IMemoryCache memoryCache)
|
public ApiController(IMemoryCache memoryCache)
|
||||||
{
|
{
|
||||||
@ -46,6 +49,7 @@ public class ApiController : Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
var response = await MastodonHelper.EnqueueStatusToFetchAsync(host, statusUrl);
|
var response = await MastodonHelper.EnqueueStatusToFetchAsync(host, statusUrl);
|
||||||
|
IndexRequests.WithLabels(host).Inc();
|
||||||
Response.Headers["instance"] = host;
|
Response.Headers["instance"] = host;
|
||||||
return Content(response, "application/activity+json");
|
return Content(response, "application/activity+json");
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,10 @@
|
|||||||
<ProjectReference Include="..\FakeRelay.Core\FakeRelay.Core.csproj" />
|
<ProjectReference Include="..\FakeRelay.Core\FakeRelay.Core.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="prometheus-net.AspNetCore" Version="7.0.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using FakeRelay.Core;
|
using FakeRelay.Core;
|
||||||
using FakeRelay.Web.Services;
|
using FakeRelay.Web.Services;
|
||||||
using Microsoft.AspNetCore.HttpOverrides;
|
using Microsoft.AspNetCore.HttpOverrides;
|
||||||
|
using Prometheus;
|
||||||
|
|
||||||
var webApplicationOptions = new WebApplicationOptions
|
var webApplicationOptions = new WebApplicationOptions
|
||||||
{
|
{
|
||||||
@ -48,4 +49,9 @@ app.MapControllerRoute(
|
|||||||
"default",
|
"default",
|
||||||
"{controller=Home}/{action=Index}/{id?}");
|
"{controller=Home}/{action=Index}/{id?}");
|
||||||
|
|
||||||
|
app.UseEndpoints(endpoints =>
|
||||||
|
{
|
||||||
|
endpoints.MapMetrics();
|
||||||
|
});
|
||||||
|
|
||||||
app.Run();
|
app.Run();
|
||||||
|
Loading…
Reference in New Issue
Block a user