test(bff): /metrics exposes http-server request duration (refs #124)

This commit is contained in:
not
2026-07-24 09:55:12 +02:00
parent 6771fccf47
commit 61805d5ce7
@@ -0,0 +1,28 @@
using System.Net;
using Microsoft.AspNetCore.Mvc.Testing;
namespace Bff.Tests;
/// <summary>
/// S-16c (#124): the service exposes OTel HTTP-server metrics in Prometheus text format at /metrics,
/// so Prometheus can scrape the golden signals (traffic, errors, latency) for the request path.
/// </summary>
public class MetricsEndpointTests(WebApplicationFactory<Program> factory)
: IClassFixture<WebApplicationFactory<Program>>
{
[Fact]
public async Task Metrics_endpoint_exposes_http_server_request_duration_after_traffic()
{
var client = factory.CreateClient();
// One request produces an http.server.request.duration measurement...
await client.GetAsync("/health");
// ...which the /metrics scrape endpoint then exposes in Prometheus text format.
var response = await client.GetAsync("/metrics");
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
var body = await response.Content.ReadAsStringAsync();
Assert.Contains("http_server_request_duration", body);
}
}