Repository navigation
Implement health endpoint based on MicroProfile Health - #480
Merged
Merged
Conversation
Signed-off-by: nscuro <[email protected]>
Owner
|
Is this ready for merge? |
Collaborator
Author
|
@stevespringett Yes, ready from my side. |
Also: * Allow checks to have multiple types, not just one * Rename `HealthCheckServlet` to `HealthServlet` * Add tests for servlet Signed-off-by: nscuro <[email protected]>
Collaborator
Author
|
Changed the way health checks are registered to a global singleton registry pattern. Service providers and Updated PR description accordingly. Definitely ready to merge now. |
Signed-off-by: nscuro <[email protected]>
2 tasks done
This file contains hidden or 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
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.
This PR implements health endpoints according to the MicroProfile Health specification.
The new
HealthServletis capable of handling the following request paths:/- Will return results of all registered health checks/live- Will return only results of registered liveness checks/ready- Will return only results of registered readiness checks/started- Will return only results of registered startup checksSee also: MicroProfile Health REST interface specification
Individual checks must implement the
HealthCheckinterface, and must be annotated with either@Liveness,@Readiness,@Startup, or a combination of the same. See Different Kinds of Health Checks.Implementations of
HealthCheckmust be registered with a globalHealthCheckRegistryinstance, e.g.:A readiness check for database connections is included in this PR.
Applications built with Alpine can add their own custom checks by following the same pattern:
HealthCheck(here: a liveness check)HealthCheckRegistry, i.e. in aServletContextListenerHealthServletviaweb.xmlExample Responses
Given the database check included in this PR, and the example custom check shown above, responses of the different endpoints would be as follows:
/{ "status": "UP", "checks": [ { "name": "custom-check", "status": "UP", "data": { "some": "data" } }, { "name": "database", "status": "UP", "data": { "nontx_connection_pool": "UP", "tx_connection_pool": "UP" } } ] }/live{ "status": "UP", "checks": [ { "name": "custom-check", "status": "UP", "data": { "some": "data" } } ] }/ready{ "status": "UP", "checks": [ { "name": "database", "status": "UP", "data": { "nontx_connection_pool": "UP", "tx_connection_pool": "UP" } } ] }/started{ "status": "UP", "checks": [] }As per the spec, the status codes returned by those endpoints are:
200- When all checks yield anUPresponse503- When at least one check yields aDOWNresponse500- When something failed while determining the status or executing checksAddresses #22