Extend traces to all rest templates in context
Also shorten names of enable flags
This commit is contained in:
@@ -30,6 +30,7 @@ import org.springframework.beans.factory.config.BeanPostProcessor;
|
||||
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.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.cloud.sleuth.Trace;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -49,6 +50,7 @@ import org.springframework.scheduling.annotation.EnableAsync;
|
||||
*/
|
||||
@Configuration
|
||||
@EnableAspectJAutoProxy
|
||||
@ConditionalOnProperty(value = "spring.sleuth.schedule.enabled", matchIfMissing = true)
|
||||
public class TraceSchedulingAutoConfiguration {
|
||||
|
||||
@ConditionalOnClass(ProceedingJoinPoint.class)
|
||||
|
||||
@@ -37,7 +37,7 @@ import org.springframework.util.StringUtils;
|
||||
* @author Spencer Gibb
|
||||
*/
|
||||
@Configuration
|
||||
@ConditionalOnProperty(value = "spring.sleuth.trace.web.enabled", matchIfMissing = true)
|
||||
@ConditionalOnProperty(value = "spring.sleuth.web.enabled", matchIfMissing = true)
|
||||
@ConditionalOnWebApplication
|
||||
public class TraceWebAutoConfiguration {
|
||||
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.springframework.cloud.sleuth.instrument.web.client;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -30,7 +32,7 @@ import org.springframework.web.client.RestTemplate;
|
||||
* @author Spencer Gibb
|
||||
*/
|
||||
@Configuration
|
||||
@ConditionalOnProperty(value = "spring.sleuth.trace.web.client.enabled", matchIfMissing = true)
|
||||
@ConditionalOnProperty(value = "spring.sleuth.client.enabled", matchIfMissing = true)
|
||||
@ConditionalOnClass(RestTemplate.class)
|
||||
public class TraceWebClientAutoConfiguration {
|
||||
|
||||
@@ -50,15 +52,17 @@ public class TraceWebClientAutoConfiguration {
|
||||
protected static class TraceInterceptorConfiguration {
|
||||
|
||||
@Autowired(required = false)
|
||||
private RestTemplate restTemplate;
|
||||
private Collection<RestTemplate> restTemplates;
|
||||
|
||||
@Autowired
|
||||
private TraceRestTemplateInterceptor traceRestTemplateInterceptor;
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
if (this.restTemplate != null) {
|
||||
this.restTemplate.getInterceptors().add(this.traceRestTemplateInterceptor);
|
||||
if (this.restTemplates != null) {
|
||||
for (RestTemplate restTemplate : this.restTemplates) {
|
||||
restTemplate.getInterceptors().add(this.traceRestTemplateInterceptor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user