Implement health endpoint based on MicroProfile Health #480
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
HealthServlet
is 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
HealthCheck
interface, and must be annotated with either@Liveness
,@Readiness
,@Startup
, or a combination of the same. See Different Kinds of Health Checks.Implementations of
HealthCheck
must be registered with a globalHealthCheckRegistry
instance, 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 aServletContextListener
HealthServlet
viaweb.xml
Example 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:
/
/live
/ready
/started
As per the spec, the status codes returned by those endpoints are:
200
- When all checks yield anUP
response503
- When at least one check yields aDOWN
response500
- When something failed while determining the status or executing checksAddresses #22