public async Task OnRequest_IncrementRequestCount() { var registry = Metrics.NewCustomRegistry(); var options = new HttpClientRequestCountOptions { Registry = registry }; var handler = new HttpClientRequestCountHandler(options); // As we are not using the HttpClientProvider for constructing our pipeline, we need to do this manually. handler.InnerHandler = new HttpClientHandler(); var client = new HttpClient(handler); await client.GetAsync("http://www.google.com"); Assert.AreEqual(1, handler._metric.WithLabels("GET", "www.google.com").Value); }
public async Task OnRequest_IncrementRequestCount() { var registry = Metrics.NewCustomRegistry(); var options = new HttpClientRequestCountOptions { Registry = registry }; var handler = new HttpClientRequestCountHandler(options, HttpClientIdentity.Default); // As we are not using the HttpClientProvider for constructing our pipeline, we need to do this manually. handler.InnerHandler = new HttpClientHandler(); var client = new HttpClient(handler); await client.GetAsync(ConnectivityCheck.Url); Assert.AreEqual(1, handler._metric.WithLabels("GET", ConnectivityCheck.Host, HttpClientIdentity.Default.Name, ConnectivityCheck.ExpectedResponseCode).Value); }