Open WernerMairl opened 6 years ago
foun some interesting project:
Prototype for ASP.NETCore 2.2: https://github.com/dotnet-architecture/HealthChecks https://github.com/Xabaril/BeatPulse
i suggest
one health Get-request for the whole app (implementing a HealthController that does the work)
one (smaller) Health-get-Method on each Controller
Usecase for "one health check per Controller)
we had false positive results in the past testing single controllers because we have tested against not existing Packages expecting HttpReturncode.NotFound
the controller was not starting on TestHost... TestHost returns HttpReturncode.NotFound => two different usecases, one returncode.... if we can do a health check (=check if Controller is running) that may help in situations like that
I just made a PR for adding basic health checks. I would think that it fills your "one health request for the whole app" suggestion, although it's really two. I understand your issue about the controller that was not started; I'm not sure how best to implement checking that a controller is loaded. The way I did my health checks is to have a health check class that get the service implementation given by the DI, like IStorageService. I could do the same for IPackageContentService for example; but that wouldn't catch the case where the PackageContentController is not started even though the the service is available in the DI container.
The use-case I am trying to solve with my basic health checks relates first to a bad configuration: maybe the database connection string is incorrect; or maybe the storage parameters point to a read-only directory, or that the Azure/AWS credentials are not found. Any of these configuration errors would make the health check fail. Secondly, another use-case is when the availability of these external resources changes. For example maybe the database went offline for an unexpected upgrade; in that case the health check would suddenly start failing.
Could you please share here what kind of error would cause a controller not starting? Is it something that can be catched with a unit test or integration test?
Feature/Pattern
https://docs.microsoft.com/en-us/azure/architecture/patterns/health-endpoint-monitoring
at least in the simplest possible way....