test(bff): /metrics exposes http-server request duration (refs #124)
This commit is contained in:
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user