2

Before in .Net 6:

app.UseRouting();
app.AddMetrics();  ( inside => app.UseMiddleware<PrometheusMetricsMiddleware>();)
app.UseEndpoints(endpoint => endpoint.MapMetrics());
app.UseHttpMetrics();

In .NET 7 we have a problem with code: app.UseEndpoints(endpoint => endpoint.MapMetrics()); ERROR - ASP0014: Suggest using top level route registrations

How can I fix it? ( without #pragma warning disable ASP0014 )

Guru Stron
  • 102,774
  • 10
  • 95
  • 132

1 Answers1

0

Try just calling MapMetrics on the app:

app.MapMetrics();
Guru Stron
  • 102,774
  • 10
  • 95
  • 132