mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-10-08 18:41:37 +00:00
Create spring-boot-health module
Closes gh-46155
This commit is contained in:
committed by
Andy Wilkinson
parent
3ecbbce773
commit
3ca1e91cde
+5
-5
@@ -581,7 +581,7 @@ You can configure the roles by using the configprop:management.endpoint.health.r
|
||||
|
||||
NOTE: If you have secured your application and wish to use `always`, your security configuration must permit access to the health endpoint for both authenticated and unauthenticated users.
|
||||
|
||||
Health information is collected from the content of a javadoc:org.springframework.boot.actuate.health.HealthContributorRegistry[] (by default, all javadoc:org.springframework.boot.actuate.health.HealthContributor[] instances defined in your javadoc:org.springframework.context.ApplicationContext[]).
|
||||
Health information is collected from the content of a javadoc:org.springframework.boot.health.registry.HealthContributorRegistry[] (by default, all javadoc:org.springframework.boot.actuate.health.HealthContributor[] instances defined in your javadoc:org.springframework.context.ApplicationContext[]).
|
||||
Spring Boot includes a number of auto-configured javadoc:org.springframework.boot.actuate.health.HealthContributor[] beans, and you can also write your own.
|
||||
|
||||
A javadoc:org.springframework.boot.actuate.health.HealthContributor[] can be either a javadoc:org.springframework.boot.actuate.health.HealthIndicator[] or a javadoc:org.springframework.boot.actuate.health.CompositeHealthContributor[].
|
||||
@@ -593,7 +593,7 @@ By default, the final system health is derived by a javadoc:org.springframework.
|
||||
The first status in the sorted list is used as the overall health status.
|
||||
If no javadoc:org.springframework.boot.actuate.health.HealthIndicator[] returns a status that is known to the javadoc:org.springframework.boot.actuate.health.StatusAggregator[], an `UNKNOWN` status is used.
|
||||
|
||||
TIP: You can use the javadoc:org.springframework.boot.actuate.health.HealthContributorRegistry[] to register and unregister health indicators at runtime.
|
||||
TIP: You can use the javadoc:org.springframework.boot.health.registry.HealthContributorRegistry[] to register and unregister health indicators at runtime.
|
||||
|
||||
|
||||
|
||||
@@ -653,7 +653,7 @@ with the `key` listed in the following table:
|
||||
| Checks that a Neo4j database is up.
|
||||
|
||||
| `ping`
|
||||
| javadoc:org.springframework.boot.actuate.health.PingHealthIndicator[]
|
||||
| javadoc:org.springframework.boot.health.contributor.PingHealthIndicator[]
|
||||
| Always responds with `UP`.
|
||||
|
||||
| `rabbit`
|
||||
@@ -771,10 +771,10 @@ The following table shows the default status mappings for the built-in statuses:
|
||||
=== Reactive Health Indicators
|
||||
|
||||
For reactive applications, such as those that use Spring WebFlux, javadoc:org.springframework.boot.actuate.health.ReactiveHealthContributor[] provides a non-blocking contract for getting application health.
|
||||
Similar to a traditional javadoc:org.springframework.boot.actuate.health.HealthContributor[], health information is collected from the content of a javadoc:org.springframework.boot.actuate.health.ReactiveHealthContributorRegistry[] (by default, all javadoc:org.springframework.boot.actuate.health.HealthContributor[] and javadoc:org.springframework.boot.actuate.health.ReactiveHealthContributor[] instances defined in your javadoc:org.springframework.context.ApplicationContext[]).
|
||||
Similar to a traditional javadoc:org.springframework.boot.actuate.health.HealthContributor[], health information is collected from the content of a javadoc:org.springframework.boot.health.registry.ReactiveHealthContributorRegistry[] (by default, all javadoc:org.springframework.boot.actuate.health.HealthContributor[] and javadoc:org.springframework.boot.actuate.health.ReactiveHealthContributor[] instances defined in your javadoc:org.springframework.context.ApplicationContext[]).
|
||||
Regular javadoc:org.springframework.boot.actuate.health.HealthContributor[] instances that do not check against a reactive API are executed on the elastic scheduler.
|
||||
|
||||
TIP: In a reactive application, you should use the javadoc:org.springframework.boot.actuate.health.ReactiveHealthContributorRegistry[] to register and unregister health indicators at runtime.
|
||||
TIP: In a reactive application, you should use the javadoc:org.springframework.boot.health.registry.ReactiveHealthContributorRegistry[] to register and unregister health indicators at runtime.
|
||||
If you need to register a regular javadoc:org.springframework.boot.actuate.health.HealthContributor[], you should wrap it with `ReactiveHealthContributor#adapt`.
|
||||
|
||||
To provide custom health information from a reactive API, you can register Spring beans that implement the javadoc:org.springframework.boot.actuate.health.ReactiveHealthIndicator[] interface.
|
||||
|
||||
+2
-2
@@ -18,8 +18,8 @@ package org.springframework.boot.docs.actuator.endpoints.health.reactivehealthin
|
||||
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import org.springframework.boot.actuate.health.Health;
|
||||
import org.springframework.boot.actuate.health.ReactiveHealthIndicator;
|
||||
import org.springframework.boot.health.contributor.Health;
|
||||
import org.springframework.boot.health.contributor.ReactiveHealthIndicator;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
|
||||
+2
-2
@@ -16,8 +16,8 @@
|
||||
|
||||
package org.springframework.boot.docs.actuator.endpoints.health.writingcustomhealthindicators;
|
||||
|
||||
import org.springframework.boot.actuate.health.Health;
|
||||
import org.springframework.boot.actuate.health.HealthIndicator;
|
||||
import org.springframework.boot.health.contributor.Health;
|
||||
import org.springframework.boot.health.contributor.HealthIndicator;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ import io.micrometer.core.instrument.Gauge;
|
||||
import io.micrometer.core.instrument.MeterRegistry;
|
||||
|
||||
import org.springframework.boot.actuate.health.HealthEndpoint;
|
||||
import org.springframework.boot.actuate.health.Status;
|
||||
import org.springframework.boot.health.contributor.Status;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
|
||||
+2
-2
@@ -16,8 +16,8 @@
|
||||
|
||||
package org.springframework.boot.docs.actuator.endpoints.health.reactivehealthindicators
|
||||
|
||||
import org.springframework.boot.actuate.health.Health
|
||||
import org.springframework.boot.actuate.health.ReactiveHealthIndicator
|
||||
import org.springframework.boot.health.contributor.Health
|
||||
import org.springframework.boot.health.contributor.ReactiveHealthIndicator
|
||||
import org.springframework.stereotype.Component
|
||||
import reactor.core.publisher.Mono
|
||||
|
||||
|
||||
+2
-2
@@ -16,8 +16,8 @@
|
||||
|
||||
package org.springframework.boot.docs.actuator.endpoints.health.writingcustomhealthindicators
|
||||
|
||||
import org.springframework.boot.actuate.health.Health
|
||||
import org.springframework.boot.actuate.health.HealthIndicator
|
||||
import org.springframework.boot.health.contributor.Health
|
||||
import org.springframework.boot.health.contributor.HealthIndicator
|
||||
import org.springframework.stereotype.Component
|
||||
|
||||
@Component
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ package org.springframework.boot.docs.howto.actuator.maphealthindicatorstometric
|
||||
import io.micrometer.core.instrument.Gauge
|
||||
import io.micrometer.core.instrument.MeterRegistry
|
||||
import org.springframework.boot.actuate.health.HealthEndpoint
|
||||
import org.springframework.boot.actuate.health.Status
|
||||
import org.springframework.boot.health.contributor.Status
|
||||
import org.springframework.context.annotation.Configuration
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
|
||||
+7
-5
@@ -22,11 +22,12 @@ import io.micrometer.core.instrument.simple.SimpleMeterRegistry;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.actuate.autoconfigure.health.HealthContributorAutoConfiguration;
|
||||
import org.springframework.boot.actuate.autoconfigure.health.HealthEndpointAutoConfiguration;
|
||||
import org.springframework.boot.actuate.health.Health;
|
||||
import org.springframework.boot.actuate.health.HealthIndicator;
|
||||
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
|
||||
import org.springframework.boot.health.autoconfigure.contributor.HealthContributorAutoConfiguration;
|
||||
import org.springframework.boot.health.autoconfigure.registry.HealthContributorRegistryAutoConfiguration;
|
||||
import org.springframework.boot.health.contributor.Health;
|
||||
import org.springframework.boot.health.contributor.HealthIndicator;
|
||||
import org.springframework.boot.metrics.autoconfigure.MetricsAutoConfiguration;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
@@ -54,7 +55,8 @@ class MetricsHealthMicrometerExportTests {
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@Import(MyHealthMetricsExportConfiguration.class)
|
||||
@ImportAutoConfiguration(classes = { HealthContributorAutoConfiguration.class, MetricsAutoConfiguration.class,
|
||||
@ImportAutoConfiguration({ HealthContributorAutoConfiguration.class,
|
||||
HealthContributorRegistryAutoConfiguration.class, MetricsAutoConfiguration.class,
|
||||
HealthEndpointAutoConfiguration.class })
|
||||
static class Config {
|
||||
|
||||
@@ -70,7 +72,7 @@ class MetricsHealthMicrometerExportTests {
|
||||
|
||||
@Bean
|
||||
HealthIndicator outOfService() {
|
||||
return () -> new Health.Builder().outOfService().build();
|
||||
return () -> Health.outOfService().build();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user