Merge pull request #33099 from artembilan
* gh-33099: Polish "Add config property for Spring Integration component observation" Add config property for Spring Integration component observation Closes gh-33099
This commit is contained in:
@@ -209,7 +209,8 @@ public class IntegrationAutoConfiguration {
|
||||
|
||||
@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 {
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2022 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.
|
||||
@@ -416,6 +416,15 @@ public class IntegrationProperties {
|
||||
*/
|
||||
private boolean defaultLoggingEnabled = true;
|
||||
|
||||
/**
|
||||
* Comma-separated list of simple patterns to match against the names of Spring
|
||||
* Integration components. When matched, observation instrumentation will be
|
||||
* performed for the component. Please refer to the javadoc of the smartMatch
|
||||
* method of Spring Integration's PatternMatchUtils for details of the pattern
|
||||
* syntax.
|
||||
*/
|
||||
private List<String> observationPatterns = new ArrayList<>();
|
||||
|
||||
public boolean isDefaultLoggingEnabled() {
|
||||
return this.defaultLoggingEnabled;
|
||||
}
|
||||
@@ -424,6 +433,14 @@ public class IntegrationProperties {
|
||||
this.defaultLoggingEnabled = defaultLoggingEnabled;
|
||||
}
|
||||
|
||||
public List<String> getObservationPatterns() {
|
||||
return this.observationPatterns;
|
||||
}
|
||||
|
||||
public void setObservationPatterns(List<String> observationPatterns) {
|
||||
this.observationPatterns = observationPatterns;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import java.util.concurrent.TimeUnit;
|
||||
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;
|
||||
@@ -62,6 +63,8 @@ import org.springframework.integration.context.IntegrationContextUtils;
|
||||
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;
|
||||
@@ -491,6 +494,17 @@ class IntegrationAutoConfigurationTests {
|
||||
|
||||
}
|
||||
|
||||
@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 {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user