Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions src/libraries/System.Net.Http/tests/FunctionalTests/MetricsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ protected static class InstrumentNames
public const string ConnectionDuration = "http.client.connection.duration";
public const string TimeInQueue = "http.client.request.time_in_queue";
}

protected HttpMetricsTestBase(ITestOutputHelper output) : base(output)
{
}
Expand Down Expand Up @@ -347,7 +347,7 @@ public Task RequestDuration_CustomTags_Recorded()
{
ctx.AddCustomTag("route", "/test");
});

using HttpResponseMessage response = await SendAsync(client, request);

Measurement<double> m = Assert.Single(recorder.GetMeasurements());
Expand Down Expand Up @@ -455,6 +455,21 @@ await LoopbackServerFactory.CreateClientAndServerAsync(async uri =>
using InstrumentRecorder<double> recorder = SetupInstrumentRecorder<double>(InstrumentNames.RequestDuration);
using HttpRequestMessage request = new(HttpMethod.Get, uri) { Version = UseVersion };
using HttpResponseMessage response = await client.SendAsync(TestAsync, request, completionOption);
string responseContent = await response.Content.ReadAsStringAsync();

if (responseContentType == ResponseContentType.ContentLength)
{
Assert.NotNull(response.Content.Headers.ContentLength);
}
else if (responseContentType == ResponseContentType.TransferEncodingChunked)
{
Assert.NotNull(response.Headers.TransferEncodingChunked);
}
else
{
// Empty
Assert.Empty(responseContent);
}

Measurement<double> m = Assert.Single(recorder.GetMeasurements());
VerifyRequestDuration(m, uri, UseVersion, 200); ;
Expand Down Expand Up @@ -783,7 +798,7 @@ await Assert.ThrowsAsync<HttpRequestException>(async () =>
using HttpResponseMessage response = await SendAsync(client, request);
});
}

Measurement<double> m = Assert.Single(recorder.GetMeasurements());
VerifyRequestDuration(m, uri, UseVersion, 200);
Assert.Equal("before!", m.Tags.ToArray().Single(t => t.Key == "before").Value);
Expand Down