diff --git a/src/MonitorWay.Tests/Integration/ErrorApiTests.cs b/src/MonitorWay.Tests/Integration/ErrorApiTests.cs index 32ee362..b63203a 100644 --- a/src/MonitorWay.Tests/Integration/ErrorApiTests.cs +++ b/src/MonitorWay.Tests/Integration/ErrorApiTests.cs @@ -32,9 +32,22 @@ public async Task ExceptionLoggedAndRecordedOnItsSpan_IsOneOccurrence() await client.GetAsync("/pay"); await client.GetAsync("/pay"); - app.Services.GetRequiredService().Tick(); - var page = await PostAsync(app, "GetErrors", new { query = new { text = "type:Timeout" } }); + // The test server answers before the request's span ends, and on .NET 11 the span is named after its route only + // then, so the traces are read once both requests have been joined to their spans. + var store = app.Services.GetRequiredService(); + ErrorsPageDto page; + var deadline = DateTime.UtcNow.AddSeconds(5); + do + { + store.Tick(); + page = await PostAsync(app, "GetErrors", new { query = new { text = "type:Timeout" } }); + if (page.Errors is [{ Endpoints: ["GET /pay"] }]) + break; + await Task.Delay(20); + } + while (DateTime.UtcNow < deadline); + var row = Assert.Single(page.Errors); Assert.Equal("System.TimeoutException", row.Type); Assert.Equal(2, row.Count);