Log a warning when a health indicator takes too long to run

Update `HealthEndpointSupport` so that it logs a warning if a health
indicator takes too long to respond.

Fixes gh-31231
This commit is contained in:
Phillip Webb
2022-06-14 09:30:13 -07:00
parent 2094722e5d
commit 9f8a262e6b
16 changed files with 192 additions and 42 deletions

View File

@@ -767,6 +767,10 @@ include::{docs-java}/actuator/endpoints/health/writingcustomhealthindicators/MyH
NOTE: The identifier for a given `HealthIndicator` is the name of the bean without the `HealthIndicator` suffix, if it exists.
In the preceding example, the health information is available in an entry named `my`.
TIP: Health indicators are usually called over HTTP and need to respond before any connection timeouts.
Spring Boot will log a warning message for any health indicator that takes longer than 10 seconds to respond.
If you want to configure this threshold, you can use the configprop:management.endpoint.health.logging.slow-indicator-threshold[] property
In addition to Spring Boot's predefined {spring-boot-actuator-module-code}/health/Status.java[`Status`] types, `Health` can return a custom `Status` that represents a new system state.
In such cases, you also need to provide a custom implementation of the {spring-boot-actuator-module-code}/health/StatusAggregator.java[`StatusAggregator`] interface, or you must configure the default implementation by using the configprop:management.endpoint.health.status.order[] configuration property.