using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Routing; using StellaOps.Scanner.WebService.Services; namespace StellaOps.Scanner.WebService.Endpoints; internal static class ObservabilityEndpoints { public static void MapObservabilityEndpoints(this IEndpointRouteBuilder endpoints) { ArgumentNullException.ThrowIfNull(endpoints); endpoints.MapGet("/metrics", HandleMetricsAsync) .WithName("scanner.metrics") .WithDescription("Exposes scanner service metrics in Prometheus text format (text/plain 0.0.4). Scraped by Prometheus without authentication.") .Produces(StatusCodes.Status200OK) .AllowAnonymous(); } private static IResult HandleMetricsAsync(OfflineKitMetricsStore metricsStore) { ArgumentNullException.ThrowIfNull(metricsStore); var payload = metricsStore.RenderPrometheus(); return Results.Text(payload, contentType: "text/plain; version=0.0.4; charset=utf-8"); } }