diff --git a/services/bff/Bff.Tests/MetricsEndpointTests.cs b/services/bff/Bff.Tests/MetricsEndpointTests.cs new file mode 100644 index 0000000..87d317f --- /dev/null +++ b/services/bff/Bff.Tests/MetricsEndpointTests.cs @@ -0,0 +1,28 @@ +using System.Net; +using Microsoft.AspNetCore.Mvc.Testing; + +namespace Bff.Tests; + +/// +/// 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. +/// +public class MetricsEndpointTests(WebApplicationFactory factory) + : IClassFixture> +{ + [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); + } +}