-
Notifications
You must be signed in to change notification settings - Fork 110
Nested paths screw up health check filters #511
Description
I'm not sure if this is even supposed to work, but it's just something I noticed while I was exploring the health checks feature. In my ConfigureServices I have the following:
services.AddHealthChecks()
.AddCheck("MyDatabase",
new SqlConnectionHealthCheck("Data Source=localhost;Initial Catalog=my-dummy-database"),
tags: new[] { "ready" });Obviously the SqlConnectionHealthCheck fails because it cannot connect to the database (in fact, there isn't even a SQL Server running on my machine). Now I have added the following to my Configure method:
app.UseHealthChecks("/health", new HealthCheckOptions {});
app.UseHealthChecks("/health/ready", new HealthCheckOptions
{
Predicate = (check) => check.Tags.Contains("ready"),
});
app.UseHealthChecks("/health/live", new HealthCheckOptions()
{
Predicate = (check) => false,
});In this setup I would expect /health to return Unhealthy, since it runs the SqlConnectionHealthCheck and it fails. This is indeed the case. The same goes for the /health/ready endpoint. However, I was expecting /health/live to return Healthy, but it does not. Instead it returns Unhealthy and looking at the log it seems to be executing the SqlConnectionHealthCheck regardless of the predicate.
Personally I would be fine with it if this is something that's not supported, but it might be useful to put this into the documentation somewhere so that users of this feature don't get tripped up.