Creating a custom database performance health check
Database performance is a critical factor in system health. A basic connection health check may not offer a thorough assessment of database performance. In this recipe, we’ll create a sophisticated, customizable database performance health check that goes beyond simple connectivity tests. We will measure query execution times, configure thresholds, and provide rich diagnostic information. This recipe can provide a template and jumping-off point to create your own custom HealthChecks
perfectly suited to your Web API.
Getting ready
- The starter project for this recipe can be found here: https://github.com/PacktPublishing/ASP.NET-9-Web-API-Cookbook/tree/main/start/chapter04/CustomHealthCheck
- Clone the starter project or continue from the previous recipe.
How to do it…
- In the
Middleware
folder, create a new file calledDatabasePerformanceOptions.cs
and fill in the code for theDatabasePerformanceOptions...