From 2d48b4b187f0032bf40e0bdc83fb7c8112e70750 Mon Sep 17 00:00:00 2001 From: James Newton-King Date: Sat, 19 Aug 2023 04:08:25 +0800 Subject: [PATCH] Update metrics.md (#30091) * Update metrics.md * Update metrics.md * Update metrics.md --- aspnetcore/log-mon/metrics/metrics.md | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/aspnetcore/log-mon/metrics/metrics.md b/aspnetcore/log-mon/metrics/metrics.md index 2f51befadb..6a8c7e4bd0 100644 --- a/aspnetcore/log-mon/metrics/metrics.md +++ b/aspnetcore/log-mon/metrics/metrics.md @@ -63,8 +63,7 @@ If the [dotnet-counters](/dotnet/core/diagnostics/dotnet-counters) tool isn't in dotnet tool update -g dotnet-counters ``` -While the test app is running, launch [dotnet-counters](/dotnet/core/diagnostics/dotnet-counters). -The following command shows an example of `dotnet-counters` monitoring all metrics from the `Microsoft.AspNetCore.Hosting` meter. +While the test app is running, launch [dotnet-counters](/dotnet/core/diagnostics/dotnet-counters). The following command shows an example of `dotnet-counters` monitoring all metrics from the `Microsoft.AspNetCore.Hosting` meter. ```dotnetcli dotnet-counters monitor -n WebMetric --counters Microsoft.AspNetCore.Hosting @@ -88,15 +87,7 @@ Press p to pause, r to resume, q to quit. host=localhost,method=GET,port=5045,protocol=HTTP/1.1,ro 0 12 ``` -Run `WebMetric>dotnet-counters list` to show all available metrics. - -The following command shows the `Microsoft-AspNetCore-Server-Kestrel` meter with the `requests-per-second` and `total-requests` counters. - -```dotnetcli -dotnet-counters monitor -n WebMetric --counters Microsoft.AspNetCore.Hosting[requests-per-second,total-requests] -``` - -For more information, see [dotnet-counters](/dotnet/core/diagnostics/dotnet-counters). To learn more about metrics in .NET, see [built-in metrics](/dotnet/core/diagnostics/available-counters). +For more information, see [dotnet-counters](/dotnet/core/diagnostics/dotnet-counters). ## Create custom metrics @@ -200,7 +191,7 @@ public class BasicTests : IClassFixture> // Assert Assert.Equal("Hello World!", await response.Content.ReadAsStringAsync()); - await collector.WaitForMeasurementsAsync(minCount: 1); + await collector.WaitForMeasurementsAsync(minCount: 1).WaitAsync(TimeSpan.FromSeconds(5)); Assert.Collection(collector.GetMeasurementSnapshot(), measurement => { @@ -219,7 +210,7 @@ The proceeding test: * Requires a package reference to `Microsoft.Extensions.Telemetry.Testing`. * The `MetricCollector` is created using the web app's `IMeterFactory`. This allows the collector to only report metrics values recorded by test. * Includes the meter name, `Microsoft.AspNetCore.Hosting`, and counter name, `http.server.request.duration` to collect. -* Makes a HTTP request to the app web. +* Makes an HTTP request to the web app. * Asserts the test using results from the metrics collector. ## ASP.NET Core meters and counters