-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Porting of composable Health Checks #591
Merged
MaxDac
merged 8 commits into
main
from
mdacunzo/feature/adding-composable-health-checks
Aug 14, 2023
Merged
Porting of composable Health Checks #591
MaxDac
merged 8 commits into
main
from
mdacunzo/feature/adding-composable-health-checks
Aug 14, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
K-Cully
requested changes
Aug 11, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Besides the comments already present, this is OSS; please add documentation.
src/Diagnostics.HealthChecks/Internal/HttpEndpointHealthCheck.cs
Outdated
Show resolved
Hide resolved
tests/Diagnostics.HealthChecks.UnitTests/HealthChecksBuilderExtensionsTests.cs
Show resolved
Hide resolved
src/Diagnostics.HealthChecks/Composables/HealthCheckComposablesExtensions.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: Keith Cully <[email protected]>
Co-authored-by: Keith Cully <[email protected]>
neilr81
approved these changes
Aug 11, 2023
K-Cully
approved these changes
Aug 14, 2023
This was referenced Aug 14, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Implements the porting of the composable Health Check classes implementation for .NET Health Checks.
Each composable class implements a different behaviour, specialising in only one responsibility, thus granting more granular maintenance and flexibility compared to an implementation that leverages a chain of inheritance. For instance, using the composition it will be theoretically possible to invert the wrapping order of the classes, or remove a composable class in the middle of the "chain".
These composable classes are the following:
ObserverHealthCheck
: this is the outermost wrapper, as it implements the exception handling and the activity definition.StartupHealthCheck
: implements the behaviour by which the health check is executed only at start-up time, to prevent the deployment of a faulty version of the application.HttpEndpointHealthCheck
: this class is the core of the HTTP Endpoint health checks, in that it performs the call to the endpoints that must be checked by the active monitoring and offers extension by the injection of aIHealthCheckResponseChecker
interface, which exposes a method that checks the response returned from the HTTP call.There are two example of different composition strategies in the project, both pointing to the load feedback endpoint:
Liveness Health Check
This health checks simply checks whether the related endpoint is reachable, and the request handling should be short circuited by the server, returning 200. This is accomplished by specifying the
MarkAsLivenessCheck
activity marker.Execution Health Check
In this case, the activity marker selected is simply the
HealthCheckActivityMarker
, which marks the activity as belonging to a health check without dictating the short-circuiting of the request by the server.This strategy should be used when the execution of the endpoint is equally important as its availability.
The short-circuiting behaviour in the server endpoint has been implemented using the Action Filter -
LivenessCheckActionFilterAttribute
, that checks whether the endpoint current activity (if existent) has been marked accordingly, as mentioned above.Implementation details
Another diagnostic package has been created to avoid adding .NET 7 specific dependencies to the project. In particular, the implementation of the activity markers for request short-circuiting and the
LivenessCheckActionFilterAttribute
dependent on ASP.NET Core dependencies have been implemented in the new package.Another Unit Test project has been created for the same purpose, as the controller endpoint filter implementation is heavily dependent on .NET 7.