Move Redis health and metrics auto-config into spring-boot-data-redis
This commit is contained in:
committed by
Phillip Webb
parent
3e72525828
commit
5d131754cc
@@ -32,7 +32,6 @@ dependencies {
|
||||
optional(project(":spring-boot-project:spring-boot-couchbase"))
|
||||
optional(project(":spring-boot-project:spring-boot-data-cassandra"))
|
||||
optional(project(":spring-boot-project:spring-boot-data-jpa"))
|
||||
optional(project(":spring-boot-project:spring-boot-data-redis"))
|
||||
optional(project(":spring-boot-project:spring-boot-http-converter"))
|
||||
optional(project(":spring-boot-project:spring-boot-http-codec"))
|
||||
optional(project(":spring-boot-project:spring-boot-jackson"))
|
||||
@@ -126,12 +125,10 @@ dependencies {
|
||||
optional("org.springframework.batch:spring-batch-core")
|
||||
optional("org.springframework.data:spring-data-couchbase")
|
||||
optional("org.springframework.data:spring-data-jpa")
|
||||
optional("org.springframework.data:spring-data-redis")
|
||||
optional("org.springframework.graphql:spring-graphql")
|
||||
optional("org.springframework.kafka:spring-kafka")
|
||||
optional("org.springframework.security:spring-security-config")
|
||||
optional("org.springframework.security:spring-security-web")
|
||||
optional("redis.clients:jedis")
|
||||
|
||||
testImplementation(project(":spring-boot-project:spring-boot-data-rest"))
|
||||
testImplementation(project(":spring-boot-project:spring-boot-hateoas"))
|
||||
|
||||
@@ -98,12 +98,6 @@
|
||||
"description": "Whether to enable readiness state health check.",
|
||||
"defaultValue": false
|
||||
},
|
||||
{
|
||||
"name": "management.health.redis.enabled",
|
||||
"type": "java.lang.Boolean",
|
||||
"description": "Whether to enable Redis health check.",
|
||||
"defaultValue": true
|
||||
},
|
||||
{
|
||||
"name": "management.health.ssl.enabled",
|
||||
"type": "java.lang.Boolean",
|
||||
|
||||
@@ -8,8 +8,6 @@ org.springframework.boot.actuate.autoconfigure.cloudfoundry.servlet.CloudFoundry
|
||||
org.springframework.boot.actuate.autoconfigure.condition.ConditionsReportEndpointAutoConfiguration
|
||||
org.springframework.boot.actuate.autoconfigure.context.properties.ConfigurationPropertiesReportEndpointAutoConfiguration
|
||||
org.springframework.boot.actuate.autoconfigure.context.ShutdownEndpointAutoConfiguration
|
||||
org.springframework.boot.actuate.autoconfigure.data.redis.RedisHealthContributorAutoConfiguration
|
||||
org.springframework.boot.actuate.autoconfigure.data.redis.RedisReactiveHealthContributorAutoConfiguration
|
||||
org.springframework.boot.actuate.autoconfigure.endpoint.jackson.JacksonEndpointAutoConfiguration
|
||||
org.springframework.boot.actuate.autoconfigure.endpoint.jmx.JmxEndpointAutoConfiguration
|
||||
org.springframework.boot.actuate.autoconfigure.env.EnvironmentEndpointAutoConfiguration
|
||||
@@ -41,7 +39,6 @@ org.springframework.boot.actuate.autoconfigure.metrics.export.statsd.StatsdMetri
|
||||
org.springframework.boot.actuate.autoconfigure.metrics.jersey.JerseyServerMetricsAutoConfiguration
|
||||
org.springframework.boot.actuate.autoconfigure.metrics.orm.jpa.HibernateMetricsAutoConfiguration
|
||||
org.springframework.boot.actuate.autoconfigure.metrics.r2dbc.ConnectionPoolMetricsAutoConfiguration
|
||||
org.springframework.boot.actuate.autoconfigure.metrics.redis.LettuceMetricsAutoConfiguration
|
||||
org.springframework.boot.actuate.autoconfigure.metrics.task.TaskExecutorMetricsAutoConfiguration
|
||||
org.springframework.boot.actuate.autoconfigure.metrics.web.jetty.JettyMetricsAutoConfiguration
|
||||
org.springframework.boot.actuate.autoconfigure.metrics.web.tomcat.TomcatMetricsAutoConfiguration
|
||||
|
||||
@@ -27,8 +27,6 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.cassandra.autoconfigure.CassandraAutoConfiguration;
|
||||
import org.springframework.boot.context.annotation.UserConfigurations;
|
||||
import org.springframework.boot.data.cassandra.autoconfigure.CassandraDataAutoConfiguration;
|
||||
import org.springframework.boot.data.redis.autoconfigure.RedisAutoConfiguration;
|
||||
import org.springframework.boot.data.redis.autoconfigure.RedisRepositoriesAutoConfiguration;
|
||||
import org.springframework.boot.data.rest.autoconfigure.RepositoryRestMvcAutoConfiguration;
|
||||
import org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner;
|
||||
import org.springframework.boot.test.context.runner.WebApplicationContextRunner;
|
||||
@@ -69,8 +67,7 @@ class WebEndpointsAutoConfigurationIntegrationTests {
|
||||
}
|
||||
|
||||
@EnableAutoConfiguration(exclude = { CassandraAutoConfiguration.class, CassandraDataAutoConfiguration.class,
|
||||
RepositoryRestMvcAutoConfiguration.class, RedisAutoConfiguration.class,
|
||||
RedisRepositoriesAutoConfiguration.class, BraveAutoConfiguration.class,
|
||||
RepositoryRestMvcAutoConfiguration.class, BraveAutoConfiguration.class,
|
||||
OpenTelemetryTracingAutoConfiguration.class })
|
||||
@SpringBootConfiguration
|
||||
static class WebEndpointTestApplication {
|
||||
|
||||
@@ -18,9 +18,10 @@ dependencies {
|
||||
|
||||
implementation(project(":spring-boot-project:spring-boot-netty"))
|
||||
|
||||
optional(project(":spring-boot-project:spring-boot-actuator"))
|
||||
optional(project(":spring-boot-project:spring-boot-actuator-autoconfigure"))
|
||||
optional(project(":spring-boot-project:spring-boot-autoconfigure"))
|
||||
optional(project(":spring-boot-project:spring-boot-docker-compose"))
|
||||
optional(project(":spring-boot-project:spring-boot-metrics"))
|
||||
optional(project(":spring-boot-project:spring-boot-testcontainers"))
|
||||
optional("com.redis:testcontainers-redis")
|
||||
optional("redis.clients:jedis")
|
||||
|
||||
@@ -14,18 +14,20 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.actuate.autoconfigure.data.redis;
|
||||
package org.springframework.boot.data.redis.actuate.health.autoconfigure;
|
||||
|
||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||
import org.springframework.boot.actuate.autoconfigure.health.CompositeHealthContributorConfiguration;
|
||||
import org.springframework.boot.actuate.autoconfigure.health.ConditionalOnEnabledHealthIndicator;
|
||||
import org.springframework.boot.actuate.health.HealthContributor;
|
||||
import org.springframework.boot.actuate.health.HealthIndicator;
|
||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.data.redis.actuate.health.RedisHealthIndicator;
|
||||
import org.springframework.boot.data.redis.autoconfigure.RedisAutoConfiguration;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
|
||||
@@ -36,11 +38,10 @@ import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
* @author Richard Santana
|
||||
* @author Stephane Nicoll
|
||||
* @author Mark Paluch
|
||||
* @since 2.1.0
|
||||
* @since 4.0.0
|
||||
*/
|
||||
@AutoConfiguration(after = RedisReactiveHealthContributorAutoConfiguration.class,
|
||||
afterName = "org.springframework.boot.data.redis.autoconfigure.RedisAutoConfiguration")
|
||||
@ConditionalOnClass({ RedisConnectionFactory.class, RedisHealthIndicator.class })
|
||||
@AutoConfiguration(after = { RedisAutoConfiguration.class, RedisReactiveHealthContributorAutoConfiguration.class })
|
||||
@ConditionalOnClass({ RedisConnectionFactory.class, HealthIndicator.class, ConditionalOnEnabledHealthIndicator.class })
|
||||
@ConditionalOnBean(RedisConnectionFactory.class)
|
||||
@ConditionalOnEnabledHealthIndicator("redis")
|
||||
public class RedisHealthContributorAutoConfiguration
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.actuate.autoconfigure.data.redis;
|
||||
package org.springframework.boot.data.redis.actuate.health.autoconfigure;
|
||||
|
||||
import reactor.core.publisher.Flux;
|
||||
|
||||
@@ -22,12 +22,14 @@ import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||
import org.springframework.boot.actuate.autoconfigure.health.CompositeReactiveHealthContributorConfiguration;
|
||||
import org.springframework.boot.actuate.autoconfigure.health.ConditionalOnEnabledHealthIndicator;
|
||||
import org.springframework.boot.actuate.health.ReactiveHealthContributor;
|
||||
import org.springframework.boot.actuate.health.ReactiveHealthIndicator;
|
||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.data.redis.actuate.health.RedisReactiveHealthIndicator;
|
||||
import org.springframework.boot.data.redis.autoconfigure.RedisReactiveAutoConfiguration;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.data.redis.connection.ReactiveRedisConnectionFactory;
|
||||
|
||||
@@ -39,10 +41,11 @@ import org.springframework.data.redis.connection.ReactiveRedisConnectionFactory;
|
||||
* @author Richard Santana
|
||||
* @author Stephane Nicoll
|
||||
* @author Mark Paluch
|
||||
* @since 2.1.0
|
||||
* @since 4.0.0
|
||||
*/
|
||||
@AutoConfiguration(afterName = "org.springframework.boot.data.redis.autoconfigure.RedisReactiveAutoConfiguration")
|
||||
@ConditionalOnClass({ ReactiveRedisConnectionFactory.class, Flux.class, RedisReactiveHealthIndicator.class })
|
||||
@AutoConfiguration(after = RedisReactiveAutoConfiguration.class)
|
||||
@ConditionalOnClass({ ReactiveRedisConnectionFactory.class, Flux.class, ReactiveHealthIndicator.class,
|
||||
ConditionalOnEnabledHealthIndicator.class })
|
||||
@ConditionalOnBean(ReactiveRedisConnectionFactory.class)
|
||||
@ConditionalOnEnabledHealthIndicator("redis")
|
||||
public class RedisReactiveHealthContributorAutoConfiguration extends
|
||||
@@ -15,6 +15,6 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Auto-configuration for actuator Redis concerns dependent on Spring Data.
|
||||
* Auto-configuration for Redis health integration using Spring Data Redis.
|
||||
*/
|
||||
package org.springframework.boot.actuate.autoconfigure.data.redis;
|
||||
package org.springframework.boot.data.redis.actuate.health.autoconfigure;
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.actuate.autoconfigure.metrics.redis;
|
||||
package org.springframework.boot.data.redis.actuate.metrics.autoconfigure;
|
||||
|
||||
import io.lettuce.core.RedisClient;
|
||||
import io.lettuce.core.metrics.MicrometerCommandLatencyRecorder;
|
||||
@@ -26,8 +26,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.data.redis.autoconfigure.ClientResourcesBuilderCustomizer;
|
||||
import org.springframework.boot.metrics.autoconfigure.CompositeMeterRegistryAutoConfiguration;
|
||||
import org.springframework.boot.metrics.autoconfigure.MetricsAutoConfiguration;
|
||||
import org.springframework.boot.data.redis.autoconfigure.RedisAutoConfiguration;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
||||
/**
|
||||
@@ -35,12 +34,11 @@ import org.springframework.context.annotation.Bean;
|
||||
*
|
||||
* @author Antonin Arquey
|
||||
* @author Yanming Zhou
|
||||
* @since 2.6.0
|
||||
* @since 4.0.0
|
||||
*/
|
||||
@AutoConfiguration(beforeName = "org.springframework.boot.data.redis.autoconfigure.RedisAutoConfiguration",
|
||||
after = { MetricsAutoConfiguration.class, CompositeMeterRegistryAutoConfiguration.class })
|
||||
@ConditionalOnClass({ ClientResourcesBuilderCustomizer.class, RedisClient.class,
|
||||
MicrometerCommandLatencyRecorder.class })
|
||||
@AutoConfiguration(before = RedisAutoConfiguration.class,
|
||||
afterName = "org.springframework.boot.metrics.autoconfigure.CompositeMeterRegistryAutoConfiguration")
|
||||
@ConditionalOnClass({ RedisClient.class, MicrometerCommandLatencyRecorder.class, MeterRegistry.class })
|
||||
@ConditionalOnBean(MeterRegistry.class)
|
||||
public class LettuceMetricsAutoConfiguration {
|
||||
|
||||
@@ -17,4 +17,4 @@
|
||||
/**
|
||||
* Auto-configuration for Redis metrics.
|
||||
*/
|
||||
package org.springframework.boot.actuate.autoconfigure.metrics.redis;
|
||||
package org.springframework.boot.data.redis.actuate.metrics.autoconfigure;
|
||||
@@ -1,6 +1,12 @@
|
||||
{
|
||||
"groups": [],
|
||||
"properties": [
|
||||
{
|
||||
"name": "management.health.redis.enabled",
|
||||
"type": "java.lang.Boolean",
|
||||
"description": "Whether to enable Redis health check.",
|
||||
"defaultValue": true
|
||||
},
|
||||
{
|
||||
"name": "spring.data.redis.repositories.enabled",
|
||||
"type": "java.lang.Boolean",
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
org.springframework.boot.data.redis.actuate.health.autoconfigure.RedisHealthContributorAutoConfiguration
|
||||
org.springframework.boot.data.redis.actuate.health.autoconfigure.RedisReactiveHealthContributorAutoConfiguration
|
||||
org.springframework.boot.data.redis.actuate.metrics.autoconfigure.LettuceMetricsAutoConfiguration
|
||||
org.springframework.boot.data.redis.autoconfigure.RedisAutoConfiguration
|
||||
org.springframework.boot.data.redis.autoconfigure.RedisReactiveAutoConfiguration
|
||||
org.springframework.boot.data.redis.autoconfigure.RedisRepositoriesAutoConfiguration
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.actuate.autoconfigure.data.redis;
|
||||
package org.springframework.boot.data.redis.actuate.health.autoconfigure;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.actuate.autoconfigure.data.redis;
|
||||
package org.springframework.boot.data.redis.actuate.health.autoconfigure;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@@ -14,14 +14,14 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.actuate.autoconfigure.metrics.redis;
|
||||
package org.springframework.boot.data.redis.actuate.metrics.autoconfigure;
|
||||
|
||||
import io.lettuce.core.metrics.MicrometerCommandLatencyRecorder;
|
||||
import io.lettuce.core.metrics.MicrometerOptions;
|
||||
import io.lettuce.core.resource.ClientResources;
|
||||
import io.micrometer.core.instrument.simple.SimpleMeterRegistry;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.metrics.test.MetricsRun;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||
import org.springframework.boot.data.redis.autoconfigure.RedisAutoConfiguration;
|
||||
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
||||
@@ -43,7 +43,7 @@ class LettuceMetricsAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
void whenThereIsAMeterRegistryThenCommandLatencyRecorderIsAdded() {
|
||||
this.contextRunner.with(MetricsRun.simple())
|
||||
this.contextRunner.withBean(SimpleMeterRegistry.class)
|
||||
.withConfiguration(AutoConfigurations.of(RedisAutoConfiguration.class))
|
||||
.run((context) -> {
|
||||
ClientResources clientResources = context.getBean(LettuceConnectionFactory.class).getClientResources();
|
||||
@@ -54,7 +54,7 @@ class LettuceMetricsAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
void autoConfiguredMicrometerOptionsUsesLettucesDefaults() {
|
||||
this.contextRunner.with(MetricsRun.simple())
|
||||
this.contextRunner.withBean(SimpleMeterRegistry.class)
|
||||
.withConfiguration(AutoConfigurations.of(RedisAutoConfiguration.class))
|
||||
.run((context) -> {
|
||||
MicrometerOptions micrometerOptions = context.getBean(MicrometerOptions.class);
|
||||
@@ -68,7 +68,7 @@ class LettuceMetricsAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
void whenUserDefinesAMicrometerOptionsBeanThenCommandLatencyRecorderUsesIt() {
|
||||
this.contextRunner.with(MetricsRun.simple())
|
||||
this.contextRunner.withBean(SimpleMeterRegistry.class)
|
||||
.withConfiguration(AutoConfigurations.of(RedisAutoConfiguration.class))
|
||||
.withUserConfiguration(CustomMicrometerOptionsConfiguration.class)
|
||||
.run((context) -> {
|
||||
Reference in New Issue
Block a user