Move R2DBC health and observation to spring-boot-r2dbc
This commit is contained in:
committed by
Phillip Webb
parent
6f05c190e1
commit
7f185a597e
@@ -41,7 +41,6 @@ dependencies {
|
||||
optional(project(":spring-boot-project:spring-boot-metrics"))
|
||||
optional(project(":spring-boot-project:spring-boot-micrometer-observation"))
|
||||
optional(project(":spring-boot-project:spring-boot-opentelemetry"))
|
||||
optional(project(":spring-boot-project:spring-boot-r2dbc"))
|
||||
optional(project(":spring-boot-project:spring-boot-restclient"))
|
||||
optional(project(":spring-boot-project:spring-boot-security-oauth2-client"))
|
||||
optional(project(":spring-boot-project:spring-boot-security-oauth2-resource-server"))
|
||||
@@ -71,9 +70,6 @@ dependencies {
|
||||
optional("io.opentelemetry:opentelemetry-exporter-otlp")
|
||||
optional("io.projectreactor.netty:reactor-netty-http")
|
||||
optional("io.prometheus:prometheus-metrics-tracer-common")
|
||||
optional("io.r2dbc:r2dbc-pool")
|
||||
optional("io.r2dbc:r2dbc-proxy")
|
||||
optional("io.r2dbc:r2dbc-spi")
|
||||
optional("jakarta.persistence:jakarta.persistence-api")
|
||||
optional("jakarta.servlet:jakarta.servlet-api")
|
||||
optional("org.apache.activemq:activemq-broker")
|
||||
@@ -119,7 +115,6 @@ dependencies {
|
||||
testImplementation("io.opentelemetry:opentelemetry-exporter-common")
|
||||
testImplementation("io.projectreactor:reactor-test")
|
||||
testImplementation("io.prometheus:prometheus-metrics-exposition-formats")
|
||||
testImplementation("io.r2dbc:r2dbc-h2")
|
||||
testImplementation("com.squareup.okhttp3:mockwebserver")
|
||||
testImplementation("jakarta.xml.bind:jakarta.xml.bind-api")
|
||||
testImplementation("org.apache.activemq:artemis-jakarta-client")
|
||||
|
||||
@@ -18,8 +18,6 @@ org.springframework.boot.actuate.autoconfigure.metrics.task.TaskExecutorMetricsA
|
||||
org.springframework.boot.actuate.autoconfigure.observability.ObservabilityAutoConfiguration
|
||||
org.springframework.boot.actuate.autoconfigure.observation.web.reactive.WebFluxObservationAutoConfiguration
|
||||
org.springframework.boot.actuate.autoconfigure.observation.web.servlet.WebMvcObservationAutoConfiguration
|
||||
org.springframework.boot.actuate.autoconfigure.r2dbc.ConnectionFactoryHealthContributorAutoConfiguration
|
||||
org.springframework.boot.actuate.autoconfigure.r2dbc.R2dbcObservationAutoConfiguration
|
||||
org.springframework.boot.actuate.autoconfigure.sbom.SbomEndpointAutoConfiguration
|
||||
org.springframework.boot.actuate.autoconfigure.scheduling.ScheduledTasksEndpointAutoConfiguration
|
||||
org.springframework.boot.actuate.autoconfigure.scheduling.ScheduledTasksObservabilityAutoConfiguration
|
||||
|
||||
@@ -19,11 +19,12 @@ dependencies {
|
||||
|
||||
compileOnly("com.fasterxml.jackson.core:jackson-annotations")
|
||||
|
||||
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-jdbc"))
|
||||
optional(project(":spring-boot-project:spring-boot-metrics"))
|
||||
optional(project(":spring-boot-project:spring-boot-micrometer-observation"))
|
||||
optional(project(":spring-boot-project:spring-boot-testcontainers"))
|
||||
optional("io.micrometer:micrometer-core")
|
||||
optional("io.r2dbc:r2dbc-pool")
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.actuate.autoconfigure.r2dbc;
|
||||
package org.springframework.boot.r2dbc.actuate.health.autoconfigure;
|
||||
|
||||
import io.r2dbc.spi.ConnectionFactory;
|
||||
|
||||
@@ -36,10 +36,10 @@ import org.springframework.context.annotation.Bean;
|
||||
* {@link ConnectionFactoryHealthIndicator}.
|
||||
*
|
||||
* @author Mark Paluch
|
||||
* @since 2.3.0
|
||||
* @since 4.0.0
|
||||
*/
|
||||
@AutoConfiguration(after = R2dbcAutoConfiguration.class)
|
||||
@ConditionalOnClass({ ConnectionFactory.class, ConnectionFactoryHealthIndicator.class })
|
||||
@ConditionalOnClass({ ConnectionFactory.class, ConditionalOnEnabledHealthIndicator.class })
|
||||
@ConditionalOnBean(ConnectionFactory.class)
|
||||
@ConditionalOnEnabledHealthIndicator("r2dbc")
|
||||
public class ConnectionFactoryHealthContributorAutoConfiguration
|
||||
@@ -51,7 +51,7 @@ public class ConnectionFactoryHealthContributorAutoConfiguration
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(name = { "r2dbcHealthIndicator", "r2dbcHealthContributor" })
|
||||
public ReactiveHealthContributor r2dbcHealthContributor(ConfigurableListableBeanFactory beanFactory) {
|
||||
ReactiveHealthContributor r2dbcHealthContributor(ConfigurableListableBeanFactory beanFactory) {
|
||||
return createContributor(beanFactory, ConnectionFactory.class);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright 2012-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Auto-configuration for R2DBC health integration.
|
||||
*/
|
||||
package org.springframework.boot.r2dbc.actuate.health.autoconfigure;
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.actuate.autoconfigure.r2dbc;
|
||||
package org.springframework.boot.r2dbc.autoconfigure.observation;
|
||||
|
||||
import io.micrometer.observation.ObservationRegistry;
|
||||
import io.r2dbc.proxy.ProxyConnectionFactory;
|
||||
@@ -30,7 +30,6 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.boot.micrometer.observation.autoconfigure.ObservationAutoConfiguration;
|
||||
import org.springframework.boot.r2dbc.OptionsCapableConnectionFactory;
|
||||
import org.springframework.boot.r2dbc.autoconfigure.ProxyConnectionFactoryCustomizer;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
@@ -41,16 +40,17 @@ import org.springframework.core.annotation.Order;
|
||||
*
|
||||
* @author Moritz Halbritter
|
||||
* @author Tadaya Tsuyukubo
|
||||
* @since 3.2.0
|
||||
* @since 4.0.0
|
||||
*/
|
||||
@AutoConfiguration(after = ObservationAutoConfiguration.class)
|
||||
@ConditionalOnClass({ ConnectionFactory.class, ProxyConnectionFactory.class })
|
||||
@AutoConfiguration(
|
||||
afterName = "org.springframework.boot.micrometer.observation.autoconfigure.ObservationAutoConfiguration")
|
||||
@ConditionalOnClass({ ConnectionFactory.class, ProxyConnectionFactory.class, ObservationRegistry.class })
|
||||
@ConditionalOnBean(ObservationRegistry.class)
|
||||
@EnableConfigurationProperties(R2dbcObservationProperties.class)
|
||||
public class R2dbcObservationAutoConfiguration {
|
||||
|
||||
/**
|
||||
* {@code @Order} value of the observation customizer.
|
||||
* @since 3.4.0
|
||||
*/
|
||||
public static final int R2DBC_PROXY_OBSERVATION_CUSTOMIZER_ORDER = 0;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.actuate.autoconfigure.r2dbc;
|
||||
package org.springframework.boot.r2dbc.autoconfigure.observation;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
@@ -15,6 +15,6 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Auto-configuration for actuator R2DBC.
|
||||
* Auto-configuration for R2DBC observation.
|
||||
*/
|
||||
package org.springframework.boot.actuate.autoconfigure.r2dbc;
|
||||
package org.springframework.boot.r2dbc.autoconfigure.observation;
|
||||
@@ -1,5 +1,7 @@
|
||||
org.springframework.boot.r2dbc.actuate.health.autoconfigure.ConnectionFactoryHealthContributorAutoConfiguration
|
||||
org.springframework.boot.r2dbc.autoconfigure.R2dbcAutoConfiguration
|
||||
org.springframework.boot.r2dbc.autoconfigure.R2dbcInitializationAutoConfiguration
|
||||
org.springframework.boot.r2dbc.autoconfigure.R2dbcProxyAutoConfiguration
|
||||
org.springframework.boot.r2dbc.autoconfigure.R2dbcTransactionManagerAutoConfiguration
|
||||
org.springframework.boot.r2dbc.autoconfigure.observation.R2dbcObservationAutoConfiguration
|
||||
org.springframework.boot.r2dbc.metrics.autoconfigure.ConnectionPoolMetricsAutoConfiguration
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.actuate.autoconfigure.r2dbc;
|
||||
package org.springframework.boot.r2dbc.actuate.health.autoconfigure;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.actuate.autoconfigure.r2dbc;
|
||||
package org.springframework.boot.r2dbc.autoconfigure.observation;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
@@ -28,9 +28,7 @@ import org.hamcrest.Matchers;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||
import org.springframework.boot.context.annotation.ImportCandidates;
|
||||
import org.springframework.boot.r2dbc.ConnectionFactoryBuilder;
|
||||
import org.springframework.boot.r2dbc.ConnectionFactoryDecorator;
|
||||
import org.springframework.boot.r2dbc.autoconfigure.ProxyConnectionFactoryCustomizer;
|
||||
@@ -55,12 +53,6 @@ class R2dbcObservationAutoConfigurationTests {
|
||||
private final ApplicationContextRunner runner = this.runnerWithoutObservationRegistry
|
||||
.withBean(ObservationRegistry.class, ObservationRegistry::create);
|
||||
|
||||
@Test
|
||||
void shouldBeRegisteredInAutoConfigurationImports() {
|
||||
assertThat(ImportCandidates.load(AutoConfiguration.class, null).getCandidates())
|
||||
.contains(R2dbcObservationAutoConfiguration.class.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldNotSupplyBeansIfObservationRegistryIsNotPresent() {
|
||||
this.runnerWithoutObservationRegistry
|
||||
Reference in New Issue
Block a user