Class ActuatorHealthStatusProvider
- All Implemented Interfaces:
HealthProvider,StatusProvider
HealthProvider, for the systemd watchdog, and as a
StatusProvider, for the systemd status.
The health contributors are those of the Spring Boot health contributor registries, the ones shown by the health endpoint, with the same names, such
as db or diskSpace. They are read on every evaluation, so that contributors registered or unregistered later are taken into account. A
composite contributor, such as the one of several data sources, is unhealthy while any of its members is, and its details are those of its unhealthy
members, under their names.
The health indicators can be limited to the members of a health group of Spring Boot Actuator, such as one set up with
management.endpoint.health.group.<name>.include: the others are neither shown in the status nor taken into account for the health. Membership is
tested as the health endpoint does, with the path of each health indicator, such as db, or db/primary for a member of a composite.
The application is unhealthy while any of the health contributors reports one of the status codes considered as unhealthy. The systemd status always
shows that health, while the watchdog is only told about it when enabled, as it lets systemd restart the application: otherwise, the application is
always healthy for the watchdog. As the health contributors often depend on external systems, whose outages may be short, reporting the unhealthy state
to the watchdog can also be delayed, with DelayableHealthProvider.setUnhealthyDelay(Duration). The systemd status always shows the actual health, without the
delay.
- Author:
- Christian Lorenz, Joao Silva
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.github.jpmsilva.jsystemd.HealthProvider
HealthProvider.Health -
Constructor Summary
ConstructorsConstructorDescriptionActuatorHealthStatusProvider(HealthContributors contributors, Set<Status> unhealthyStatusCodes, Predicate<String> member, boolean health) Creates a new instance using the provided health contributors and unhealthy status codes. -
Method Summary
Modifier and TypeMethodDescriptionprotected HealthProvider.HealthProvides the health of the application for the watchdog, without the delay: always healthy unless reporting the unhealthy state to the watchdog is enabled.status()Provides the application health for the systemd status, naming the unhealthy contributors, if any.Methods inherited from class com.github.jpmsilva.jsystemd.DelayableHealthProvider
getUnhealthyDelay, health, setUnhealthyDelay
-
Constructor Details
-
ActuatorHealthStatusProvider
public ActuatorHealthStatusProvider(HealthContributors contributors, Set<Status> unhealthyStatusCodes, Predicate<String> member, boolean health) Creates a new instance using the provided health contributors and unhealthy status codes.- Parameters:
contributors- the health contributors, such as the Spring Boot health contributor registry: the details of each unhealthy contributor are reported under its nameunhealthyStatusCodes- the status codes considered as unhealthymember- tells if a health indicator, by its path, such asdbordb/primary, is shown in the status and taken into account for the health, such asHealthEndpointGroup.isMember(String), orname -> truefor all of themhealth-trueto report the unhealthy state to the watchdog,falseto only show it in the systemd status
-
-
Method Details
-
evaluateHealth
Provides the health of the application for the watchdog, without the delay: always healthy unless reporting the unhealthy state to the watchdog is enabled.- Specified by:
evaluateHealthin classDelayableHealthProvider- Returns:
- the health of the application for the watchdog
-
status
Provides the application health for the systemd status, naming the unhealthy contributors, if any.The details of the unhealthy contributors are left out, as they often contain sensitive information (error messages, host names, paths, ...), and the systemd status can be read by any local user, for instance with
systemctl status, regardless of how health details are exposed by Spring Boot Actuator. The details are logged instead when the watchdog heartbeat is suppressed.- Specified by:
statusin interfaceStatusProvider- Returns:
- the application health, such as
health status: unhealthy (db, redis)
-