Added hystrix to skip pattern of scheduled and messaging channel name

fixes gh-986
This commit is contained in:
Marcin Grzejszczak
2018-05-22 18:57:36 +02:00
parent 70ff3afc7b
commit 2190cccb8c
5 changed files with 33 additions and 14 deletions

View File

@@ -46,8 +46,26 @@ public class SleuthMessagingProperties {
}
public static class Integration {
/**
* An array of patterns against which channel names will be matched.
* @see org.springframework.integration.config.GlobalChannelInterceptor#patterns().
* Defaults to any channel name not matching the Hystrix Stream channel name.
*/
private String[] patterns = new String[] { "!hystrixStreamOutput*", "*" };
/**
* Enable Spring Integration sleuth instrumentation
*/
private boolean enabled;
public String[] getPatterns() {
return this.patterns;
}
public void setPatterns(String[] patterns) {
this.patterns = patterns;
}
public boolean isEnabled() {
return this.enabled;
}

View File

@@ -25,6 +25,7 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties
import org.springframework.cloud.sleuth.autoconfig.TraceAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.integration.channel.interceptor.GlobalChannelInterceptorWrapper;
import org.springframework.integration.config.GlobalChannelInterceptor;
/**
@@ -47,8 +48,16 @@ import org.springframework.integration.config.GlobalChannelInterceptor;
public class TraceSpringIntegrationAutoConfiguration {
@Bean
@GlobalChannelInterceptor(patterns = "${spring.sleuth.integration.patterns:*}")
public TracingChannelInterceptor traceChannelInterceptor(Tracing tracing) {
public GlobalChannelInterceptorWrapper tracingGlobalChannelInterceptorWrapper(
TracingChannelInterceptor interceptor,
SleuthMessagingProperties properties) {
GlobalChannelInterceptorWrapper wrapper = new GlobalChannelInterceptorWrapper(interceptor);
wrapper.setPatterns(properties.getIntegration().getPatterns());
return wrapper;
}
@Bean
TracingChannelInterceptor traceChannelInterceptor(Tracing tracing) {
return new TracingChannelInterceptor(tracing);
}

View File

@@ -35,7 +35,7 @@ public class SleuthSchedulingProperties {
/**
* Pattern for the fully qualified name of a class that should be skipped.
*/
private String skipPattern = "";
private String skipPattern = "org.springframework.cloud.netflix.hystrix.stream.HystrixStreamTask";
public boolean isEnabled() {
return this.enabled;

View File

@@ -1,10 +1,4 @@
{"properties": [
{
"name": "spring.sleuth.integration.patterns",
"type": "java.lang.String[]",
"description": "An array of simple patterns against which channel names will be matched. Default is * (all channels). See org.springframework.util.PatternMatchUtils.simpleMatch(String, String).",
"defaultValue": "*"
},
{
"name": "spring.sleuth.integration.enabled",
"type": "java.lang.Boolean",