From 85efbeb8a83bc0d0bea1c7b9df92b15a4090b96e Mon Sep 17 00:00:00 2001 From: Rick Anderson <3605364+Rick-Anderson@users.noreply.github.com> Date: Wed, 11 Oct 2023 16:43:05 -1000 Subject: [PATCH] Update metrics.md (#30663) * Update metrics.md * Update metrics.md --- aspnetcore/log-mon/metrics/metrics.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/aspnetcore/log-mon/metrics/metrics.md b/aspnetcore/log-mon/metrics/metrics.md index 42d2a48cd6..2a74c82599 100644 --- a/aspnetcore/log-mon/metrics/metrics.md +++ b/aspnetcore/log-mon/metrics/metrics.md @@ -4,7 +4,7 @@ description: Metrics for ASP.NET Core apps author: rick-anderson ms.author: riande monikerRange: '>= aspnetcore-8.0' -ms.date: 6/30/2023 +ms.date: 7/30/2023 ms.topic: article ms.prod: aspnet-core uid: log-mon/metrics/metrics @@ -226,14 +226,15 @@ Alternatively, enter counter category such as `kestrel` in the **Expression** in ## Test metrics in ASP.NET Core apps -It's possible to test metrics in ASP.NET Core apps. One way to do that is collect and assert metrics values in [ASP.NET Core integration tests](xref:test/integration-tests) using . +It's possible to test metrics in ASP.NET Core apps. One way to do that is collect and assert metrics values in [ASP.NET Core integration tests](xref:test/integration-tests) using [MetricCollector](https://learn.microsoft.com/dotnet/api/microsoft.extensions.telemetry.testing.metering.metriccollector-1?view=dotnet-plat-ext-8.0). :::code language="csharp" source="~/log-mon/metrics/metrics/samples/metric-tests/BasicTests.cs" id="snippet_TestClass"::: The proceeding test: * Bootstraps a web app in memory with . `Program` in the factory's generic argument specifies the web app. -* Collects metrics values with . +* Collects metrics values with [MetricCollector](https://learn.microsoft.com/dotnet/api/microsoft.extensions.telemetry.testing.metering.metriccollector-1?view=dotnet-plat-ext-8.0). + * Requires a package reference to `Microsoft.Extensions.Telemetry.Testing`. * The `MetricCollector` is created using the web app's . 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.