aspnetcore/release-notes/aspnetcore-9/includes/opt_out_metrics.md
.NET 9 introduces the ability to opt-out of HTTP metrics for specific endpoints and requests. Opting out of recording metrics is beneficial for endpoints frequently called by automated systems, such as health checks. Recording metrics for these requests is generally unnecessary.
HTTP requests to an endpoint can be excluded from metrics by adding metadata. Either:
[DisableHttpMetrics] attribute to the Web API controller, SignalR hub or gRPC service.:::code language="csharp" source="~/release-notes/aspnetcore-9/samples/Metrics/Program.cs" id="snippet_1" highlight="5":::
The MetricsDisabled property has been added to IHttpMetricsTagsFeature for:
:::code language="csharp" source="~/release-notes/aspnetcore-9/samples/Metrics/Program.cs" id="snippet_2":::