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
@@ -4,11 +4,13 @@ using Heimdall.Agent;
|
||||
using Heimdall.Agent.Logging;
|
||||
using Heimdall.Agent.Services;
|
||||
using Heimdall.Application.Discovery;
|
||||
using Heimdall.Application.Metrics;
|
||||
using Microsoft.AspNetCore.DataProtection;
|
||||
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
|
||||
using Microsoft.Extensions.Diagnostics.HealthChecks;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using OpenTelemetry.Metrics;
|
||||
|
||||
var builder = WebApplication.CreateSlimBuilder(args);
|
||||
|
||||
@@ -122,6 +124,14 @@ builder.Services.AddHostedService<LogUploadService>();
|
||||
builder.Services.AddHealthChecks()
|
||||
.AddCheck<AgentHealthCheck>("agent_health", tags: ["ready"]);
|
||||
|
||||
// ── OpenTelemetry metrics (spec 13.1) ──────────────────────────────
|
||||
builder.Services.AddOpenTelemetry()
|
||||
.WithMetrics(metrics =>
|
||||
{
|
||||
metrics.AddPrometheusExporter();
|
||||
metrics.AddMeter(HeimdallMetrics.MeterName);
|
||||
});
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Health endpoint
|
||||
@@ -136,4 +146,7 @@ app.MapHealthChecks("/healthz", new HealthCheckOptions
|
||||
}
|
||||
});
|
||||
|
||||
// ── Prometheus metrics endpoint (spec 13.1) ────────────────────────
|
||||
app.MapPrometheusScrapingEndpoint("/metrics");
|
||||
|
||||
await app.RunAsync();
|
||||
Reference in new issue
Block a user