Metadata to exclude request from http.server.request.duration metric #50654
Closed
Description
Is there an existing issue for this?
- I have searched the existing issues
Is your feature request related to a problem? Please describe the problem.
Every request that comes into ASP.NET Core is recorded to the http.server.request.duration
metric. There are some situations where its desirable to opt out of that behavior:
- Prometheus
/metrics
scraping endpoint - Healthchecks
/heathz
endpoint
Excluding system endpoints that are regularly requested is useful because they distort results.
Describe the solution you'd like
Add metadata that can be used to skip recording the request. Then, an app can configure endpoints with the metadata to exclude them from recording the HTTP metric.
It could be an SuppressHttpMetric()
extension method:
app.MapPrometheusScrapingEndpoint().SuppressHttpMetric();
Or attribute:
[HttpGet]
[SuppressHttpMetric]
public IActionResult GetHealth()
{
// ...
}
Some libraries might automatically include the metadata, e.g. OTel's PrometheusScapingEndpoint
internally adds the metadata when it creates the endpoint.
Additional context
No response