Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a configuration property for the observation patterns of Spring Integration components #33099

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -209,7 +209,8 @@ protected static class IntegrationManagementConfiguration {

@Configuration(proxyBeanMethods = false)
@EnableIntegrationManagement(
defaultLoggingEnabled = "${spring.integration.management.default-logging-enabled:true}")
defaultLoggingEnabled = "${spring.integration.management.default-logging-enabled:true}",
observationPatterns = "${spring.integration.management.observation-patterns:}")
protected static class EnableIntegrationManagementConfiguration {

}
Expand Down
Expand Up @@ -416,6 +416,12 @@ public static class Management {
*/
private boolean defaultLoggingEnabled = true;

/**
* Comma-separated simple patterns to match integration components for observation
* instrumentation.
*/
private List<String> observationPatterns = new ArrayList<>();

public boolean isDefaultLoggingEnabled() {
return this.defaultLoggingEnabled;
}
Expand All @@ -424,6 +430,14 @@ public void setDefaultLoggingEnabled(boolean defaultLoggingEnabled) {
this.defaultLoggingEnabled = defaultLoggingEnabled;
}

public List<String> getObservationPatterns() {
return this.observationPatterns;
}

public void setObservationPatterns(List<String> observationPatterns) {
this.observationPatterns = observationPatterns;
}

}

}
Expand Up @@ -24,6 +24,7 @@
import javax.management.MBeanServer;
import javax.sql.DataSource;

import io.micrometer.observation.ObservationRegistry;
import io.rsocket.transport.ClientTransport;
import io.rsocket.transport.netty.client.TcpClientTransport;
import org.assertj.core.api.InstanceOfAssertFactories;
Expand Down Expand Up @@ -62,6 +63,8 @@
import org.springframework.integration.core.MessageSource;
import org.springframework.integration.endpoint.MessageProcessorMessageSource;
import org.springframework.integration.gateway.RequestReplyExchanger;
import org.springframework.integration.handler.BridgeHandler;
import org.springframework.integration.handler.LoggingHandler;
import org.springframework.integration.handler.MessageProcessor;
import org.springframework.integration.rsocket.ClientRSocketConnector;
import org.springframework.integration.rsocket.IntegrationRSocketEndpoint;
Expand Down Expand Up @@ -491,6 +494,17 @@ void integrationManagementLoggingCanBeDisabled() {

}

@Test
void integrationManagementInstrumentedWithObservation() {
this.contextRunner.withPropertyValues("spring.integration.management.observation-patterns=testHandler")
.withBean("testHandler", LoggingHandler.class, () -> new LoggingHandler("warn"))
.withBean(ObservationRegistry.class, ObservationRegistry::create)
.withBean(BridgeHandler.class, BridgeHandler::new).run((context) -> {
assertThat(context).getBean("testHandler").extracting("observationRegistry").isNotNull();
assertThat(context).getBean(BridgeHandler.class).extracting("observationRegistry").isNull();
});
}

@Configuration(proxyBeanMethods = false)
static class CustomMBeanExporter {

Expand Down
2 changes: 1 addition & 1 deletion spring-boot-project/spring-boot-dependencies/build.gradle
Expand Up @@ -1379,7 +1379,7 @@ bom {
]
}
}
library("Spring Integration", "6.0.0-RC2") {
library("Spring Integration", "6.0.0-SNAPSHOT") {
group("org.springframework.integration") {
imports = [
"spring-integration-bom"
Expand Down