feat(metrics): métriques OpenTelemetry Prometheus (spec §13.1) (#161)
This commit is contained in:
1 parent
7a89a97bf3
commit
2d1734114f
17 files changed
+439
No files matched your search
@@ -5,6 +5,7 @@ using System.Security.Claims;
|
||||
using System.Text;
|
||||
using FluentValidation.AspNetCore;
|
||||
using Heimdall.Application;
|
||||
using Heimdall.Application.Metrics;
|
||||
using Heimdall.Application.Services;
|
||||
using Heimdall.Infrastructure;
|
||||
using Heimdall.Infrastructure.Data;
|
||||
@@ -18,6 +19,7 @@ using Hangfire;
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
using Microsoft.AspNetCore.Authentication.Cookies;
|
||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||
using OpenTelemetry.Metrics;
|
||||
using Microsoft.AspNetCore.Components.Authorization;
|
||||
using Microsoft.AspNetCore.RateLimiting;
|
||||
using System.Threading.RateLimiting;
|
||||
@@ -407,6 +409,17 @@ public partial class Program
|
||||
ConfigureControllers(builder);
|
||||
ConfigureSignalR(builder);
|
||||
|
||||
// ── OpenTelemetry metrics (spec 13.1) ──────────────────────────────
|
||||
// Expose Heimdall metrics via Prometheus /metrics endpoint.
|
||||
// Auto-instruments ASP.NET Core HTTP request metrics.
|
||||
builder.Services.AddOpenTelemetry()
|
||||
.WithMetrics(metrics =>
|
||||
{
|
||||
metrics.AddPrometheusExporter();
|
||||
metrics.AddAspNetCoreInstrumentation();
|
||||
metrics.AddMeter(HeimdallMetrics.MeterName);
|
||||
});
|
||||
|
||||
builder.Services.AddApplication();
|
||||
builder.Services.AddInfrastructure(builder.Configuration);
|
||||
ConfigureSentry(builder);
|
||||
@@ -793,6 +806,11 @@ public partial class Program
|
||||
});
|
||||
|
||||
app.UseRateLimiter();
|
||||
|
||||
// ── Prometheus metrics endpoint (spec 13.1) ────────────────────────
|
||||
// /metrics — scraped by Prometheus. No auth (internal network only).
|
||||
app.MapPrometheusScrapingEndpoint("/metrics");
|
||||
|
||||
MapAuthEndpoints(app);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user