Removed some package dependencies
* TraceKeys -> moved to root
* TraceRunnable and TraceCallable moved to root
* Websockets moved as a subpackage of messaging
* created TraceMetricsAutoConfiguration in the metric package (thanks to this the TraeAutoConfiguration doesn't need any metric info)
What’s left?
* the remaining dependencies are related to everybody using events
* there are a couple of usages of NeverSample
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2015 the original author or authors.
|
||||
* Copyright 2013-2016 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.
|
||||
@@ -14,14 +14,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.sleuth.instrument.async;
|
||||
package org.springframework.cloud.sleuth;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import org.springframework.cloud.sleuth.Span;
|
||||
import org.springframework.cloud.sleuth.SpanNamer;
|
||||
import org.springframework.cloud.sleuth.Tracer;
|
||||
|
||||
/**
|
||||
* Callable that passes Span between threads. The Span name is
|
||||
* taken either from the passed value or from the {@link SpanNamer}
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.sleuth.instrument;
|
||||
package org.springframework.cloud.sleuth;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashSet;
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2015 the original author or authors.
|
||||
* Copyright 2013-2016 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.
|
||||
@@ -14,11 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.sleuth.instrument.async;
|
||||
|
||||
import org.springframework.cloud.sleuth.Span;
|
||||
import org.springframework.cloud.sleuth.SpanNamer;
|
||||
import org.springframework.cloud.sleuth.Tracer;
|
||||
package org.springframework.cloud.sleuth;
|
||||
|
||||
/**
|
||||
* Runnable that passes Span between threads. The Span name is
|
||||
@@ -18,22 +18,14 @@ package org.springframework.cloud.sleuth.autoconfig;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.springframework.boot.actuate.metrics.CounterService;
|
||||
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.ConditionalOnMissingClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.cloud.sleuth.DefaultSpanNamer;
|
||||
import org.springframework.cloud.sleuth.Sampler;
|
||||
import org.springframework.cloud.sleuth.SpanNamer;
|
||||
import org.springframework.cloud.sleuth.Tracer;
|
||||
import org.springframework.cloud.sleuth.instrument.TraceKeys;
|
||||
import org.springframework.cloud.sleuth.metric.CounterServiceBasedSpanReporterService;
|
||||
import org.springframework.cloud.sleuth.metric.NoOpSpanReporterService;
|
||||
import org.springframework.cloud.sleuth.metric.SleuthMetricProperties;
|
||||
import org.springframework.cloud.sleuth.metric.SpanReporterService;
|
||||
import org.springframework.cloud.sleuth.TraceKeys;
|
||||
import org.springframework.cloud.sleuth.sampler.NeverSampler;
|
||||
import org.springframework.cloud.sleuth.trace.DefaultTracer;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
@@ -68,12 +60,6 @@ public class TraceAutoConfiguration {
|
||||
return new DefaultTracer(sampler, random, publisher, spanNamer);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public SleuthMetricProperties sleuthMetricProperties() {
|
||||
return new SleuthMetricProperties();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public TraceKeys traceKeys() {
|
||||
@@ -86,30 +72,4 @@ public class TraceAutoConfiguration {
|
||||
return new DefaultSpanNamer();
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@ConditionalOnClass(CounterService.class)
|
||||
@ConditionalOnMissingBean(SpanReporterService.class)
|
||||
protected static class CounterServiceSpanReporterConfig {
|
||||
@Bean
|
||||
@ConditionalOnBean(CounterService.class)
|
||||
public SpanReporterService spanReporterCounterService(CounterService counterService,
|
||||
SleuthMetricProperties sleuthMetricProperties) {
|
||||
return new CounterServiceBasedSpanReporterService(sleuthMetricProperties.getSpan().getAcceptedName(),
|
||||
sleuthMetricProperties.getSpan().getDroppedName(), counterService);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(CounterService.class)
|
||||
public SpanReporterService noOpSpanReporterCounterService() {
|
||||
return new NoOpSpanReporterService();
|
||||
}
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingClass("org.springframework.boot.actuate.metrics.CounterService")
|
||||
@ConditionalOnMissingBean(SpanReporterService.class)
|
||||
public SpanReporterService noOpSpanReporterCounterService() {
|
||||
return new NoOpSpanReporterService();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.cloud.sleuth.instrument;
|
||||
|
||||
import org.springframework.cloud.sleuth.Span;
|
||||
import org.springframework.cloud.sleuth.TraceKeys;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.cloud.sleuth.Tracer;
|
||||
import org.springframework.cloud.sleuth.instrument.TraceKeys;
|
||||
import org.springframework.cloud.sleuth.TraceKeys;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.task.SimpleAsyncTaskExecutor;
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||
import org.springframework.cloud.sleuth.DefaultSpanNamer;
|
||||
import org.springframework.cloud.sleuth.SpanNamer;
|
||||
import org.springframework.cloud.sleuth.Tracer;
|
||||
import org.springframework.cloud.sleuth.instrument.TraceKeys;
|
||||
import org.springframework.cloud.sleuth.TraceKeys;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
|
||||
@@ -20,8 +20,9 @@ import java.util.concurrent.Callable;
|
||||
|
||||
import org.springframework.cloud.sleuth.Span;
|
||||
import org.springframework.cloud.sleuth.SpanNamer;
|
||||
import org.springframework.cloud.sleuth.TraceCallable;
|
||||
import org.springframework.cloud.sleuth.Tracer;
|
||||
import org.springframework.cloud.sleuth.instrument.TraceKeys;
|
||||
import org.springframework.cloud.sleuth.TraceKeys;
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
@@ -18,8 +18,9 @@ package org.springframework.cloud.sleuth.instrument.async;
|
||||
|
||||
import org.springframework.cloud.sleuth.Span;
|
||||
import org.springframework.cloud.sleuth.SpanNamer;
|
||||
import org.springframework.cloud.sleuth.TraceRunnable;
|
||||
import org.springframework.cloud.sleuth.Tracer;
|
||||
import org.springframework.cloud.sleuth.instrument.TraceKeys;
|
||||
import org.springframework.cloud.sleuth.TraceKeys;
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
@@ -21,7 +21,7 @@ import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.springframework.cloud.sleuth.Span;
|
||||
import org.springframework.cloud.sleuth.Tracer;
|
||||
import org.springframework.cloud.sleuth.instrument.TraceKeys;
|
||||
import org.springframework.cloud.sleuth.TraceKeys;
|
||||
|
||||
/**
|
||||
* Aspect that creates a new Span for running threads executing methods annotated with
|
||||
|
||||
@@ -20,6 +20,7 @@ import java.util.concurrent.Callable;
|
||||
|
||||
import org.springframework.cloud.sleuth.Span;
|
||||
import org.springframework.cloud.sleuth.SpanNamer;
|
||||
import org.springframework.cloud.sleuth.TraceCallable;
|
||||
import org.springframework.cloud.sleuth.Tracer;
|
||||
|
||||
/**
|
||||
|
||||
@@ -26,7 +26,7 @@ import java.util.concurrent.TimeoutException;
|
||||
|
||||
import org.springframework.cloud.sleuth.SpanNamer;
|
||||
import org.springframework.cloud.sleuth.Tracer;
|
||||
import org.springframework.cloud.sleuth.instrument.TraceKeys;
|
||||
import org.springframework.cloud.sleuth.TraceKeys;
|
||||
|
||||
/**
|
||||
* A decorator class for {@link ExecutorService} to support tracing in Executors
|
||||
|
||||
@@ -23,7 +23,7 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.springframework.cloud.sleuth.SpanNamer;
|
||||
import org.springframework.cloud.sleuth.Tracer;
|
||||
import org.springframework.cloud.sleuth.instrument.TraceKeys;
|
||||
import org.springframework.cloud.sleuth.TraceKeys;
|
||||
|
||||
/**
|
||||
* A decorator class for {@link ScheduledExecutorService} to support tracing in Executors
|
||||
|
||||
@@ -3,7 +3,7 @@ package org.springframework.cloud.sleuth.instrument.hystrix;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.cloud.sleuth.Tracer;
|
||||
import org.springframework.cloud.sleuth.instrument.TraceKeys;
|
||||
import org.springframework.cloud.sleuth.TraceKeys;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
package org.springframework.cloud.sleuth.instrument.hystrix;
|
||||
|
||||
import javax.annotation.PreDestroy;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import com.netflix.hystrix.strategy.HystrixPlugins;
|
||||
import com.netflix.hystrix.strategy.concurrency.HystrixConcurrencyStrategy;
|
||||
import javax.annotation.PreDestroy;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.cloud.sleuth.Span;
|
||||
import org.springframework.cloud.sleuth.Tracer;
|
||||
import org.springframework.cloud.sleuth.instrument.TraceKeys;
|
||||
import org.springframework.cloud.sleuth.TraceKeys;
|
||||
|
||||
import com.netflix.hystrix.strategy.HystrixPlugins;
|
||||
import com.netflix.hystrix.strategy.concurrency.HystrixConcurrencyStrategy;
|
||||
|
||||
public class SleuthHystrixConcurrencyStrategy extends HystrixConcurrencyStrategy {
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.springframework.cloud.sleuth.instrument.hystrix;
|
||||
|
||||
import org.springframework.cloud.sleuth.Span;
|
||||
import org.springframework.cloud.sleuth.Tracer;
|
||||
import org.springframework.cloud.sleuth.instrument.TraceKeys;
|
||||
import org.springframework.cloud.sleuth.TraceKeys;
|
||||
|
||||
import com.netflix.hystrix.HystrixCommand;
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import java.util.Random;
|
||||
|
||||
import org.springframework.cloud.sleuth.Span;
|
||||
import org.springframework.cloud.sleuth.Tracer;
|
||||
import org.springframework.cloud.sleuth.instrument.TraceKeys;
|
||||
import org.springframework.cloud.sleuth.TraceKeys;
|
||||
import org.springframework.integration.channel.AbstractMessageChannel;
|
||||
import org.springframework.integration.context.IntegrationObjectSupport;
|
||||
import org.springframework.messaging.Message;
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.cloud.sleuth.Span;
|
||||
import org.springframework.cloud.sleuth.instrument.TraceKeys;
|
||||
import org.springframework.cloud.sleuth.TraceKeys;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.support.MessageBuilder;
|
||||
import org.springframework.messaging.support.MessageHeaderAccessor;
|
||||
|
||||
@@ -20,7 +20,7 @@ import java.util.Random;
|
||||
|
||||
import org.springframework.cloud.sleuth.Span;
|
||||
import org.springframework.cloud.sleuth.Tracer;
|
||||
import org.springframework.cloud.sleuth.instrument.TraceKeys;
|
||||
import org.springframework.cloud.sleuth.TraceKeys;
|
||||
import org.springframework.cloud.sleuth.sampler.NeverSampler;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.cloud.sleuth.Tracer;
|
||||
import org.springframework.cloud.sleuth.autoconfig.TraceAutoConfiguration;
|
||||
import org.springframework.cloud.sleuth.instrument.TraceKeys;
|
||||
import org.springframework.cloud.sleuth.TraceKeys;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.integration.config.GlobalChannelInterceptor;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.springframework.cloud.sleuth.instrument.websocket;
|
||||
package org.springframework.cloud.sleuth.instrument.messaging.websocket;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
@@ -6,7 +6,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.cloud.sleuth.Tracer;
|
||||
import org.springframework.cloud.sleuth.instrument.TraceKeys;
|
||||
import org.springframework.cloud.sleuth.TraceKeys;
|
||||
import org.springframework.cloud.sleuth.instrument.messaging.TraceChannelInterceptor;
|
||||
import org.springframework.messaging.simp.config.ChannelRegistration;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -31,7 +31,7 @@ import org.springframework.cloud.sleuth.Span.SpanBuilder;
|
||||
import org.springframework.cloud.sleuth.Tracer;
|
||||
import org.springframework.cloud.sleuth.event.ServerReceivedEvent;
|
||||
import org.springframework.cloud.sleuth.event.ServerSentEvent;
|
||||
import org.springframework.cloud.sleuth.instrument.TraceKeys;
|
||||
import org.springframework.cloud.sleuth.TraceKeys;
|
||||
import org.springframework.cloud.sleuth.sampler.NeverSampler;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
|
||||
@@ -44,7 +44,7 @@ import org.springframework.web.context.request.async.WebAsyncTask;
|
||||
* </ul>
|
||||
* <p/>
|
||||
* For controllers an around aspect is created that wraps the {@link Callable#call()}
|
||||
* method execution in {@link org.springframework.cloud.sleuth.instrument.async.TraceCallable}
|
||||
* method execution in {@link org.springframework.cloud.sleuth.TraceCallable}
|
||||
* <p/>
|
||||
*
|
||||
* This aspect will continue a span created by the TraceFilter. It will not create
|
||||
@@ -54,9 +54,9 @@ import org.springframework.web.context.request.async.WebAsyncTask;
|
||||
* @see org.springframework.web.bind.annotation.RestController
|
||||
* @see org.springframework.stereotype.Controller
|
||||
* @see org.springframework.web.client.RestOperations
|
||||
* @see org.springframework.cloud.sleuth.instrument.async.TraceCallable
|
||||
* @see Tracer
|
||||
* @see TraceFilter
|
||||
* @see org.springframework.cloud.sleuth.TraceCallable
|
||||
* @see org.springframework.cloud.sleuth.Tracer
|
||||
* @see org.springframework.cloud.sleuth.instrument.web.TraceFilter
|
||||
*
|
||||
* @author Tomasz Nurkewicz, 4financeIT
|
||||
* @author Marcin Grzejszczak, 4financeIT
|
||||
|
||||
@@ -30,7 +30,7 @@ import org.springframework.cloud.sleuth.SpanAccessor;
|
||||
import org.springframework.cloud.sleuth.SpanNamer;
|
||||
import org.springframework.cloud.sleuth.Tracer;
|
||||
import org.springframework.cloud.sleuth.autoconfig.TraceAutoConfiguration;
|
||||
import org.springframework.cloud.sleuth.instrument.TraceKeys;
|
||||
import org.springframework.cloud.sleuth.TraceKeys;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@@ -26,7 +26,7 @@ import feign.InvocationHandlerFactory;
|
||||
import feign.InvocationHandlerFactory.MethodHandler;
|
||||
import feign.Target;
|
||||
import org.springframework.cloud.sleuth.Tracer;
|
||||
import org.springframework.cloud.sleuth.instrument.TraceKeys;
|
||||
import org.springframework.cloud.sleuth.TraceKeys;
|
||||
import org.springframework.cloud.sleuth.instrument.hystrix.TraceCommand;
|
||||
|
||||
import static feign.Util.checkNotNull;
|
||||
|
||||
@@ -40,7 +40,7 @@ import org.springframework.cloud.sleuth.SpanAccessor;
|
||||
import org.springframework.cloud.sleuth.Tracer;
|
||||
import org.springframework.cloud.sleuth.event.ClientReceivedEvent;
|
||||
import org.springframework.cloud.sleuth.event.ClientSentEvent;
|
||||
import org.springframework.cloud.sleuth.instrument.TraceKeys;
|
||||
import org.springframework.cloud.sleuth.TraceKeys;
|
||||
import org.springframework.cloud.sleuth.instrument.hystrix.SleuthHystrixAutoConfiguration;
|
||||
import org.springframework.cloud.sleuth.instrument.hystrix.SleuthHystrixConcurrencyStrategy;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright 2013-2016 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
|
||||
*
|
||||
* http://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.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.sleuth.metric;
|
||||
|
||||
import org.springframework.boot.actuate.metrics.CounterService;
|
||||
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.ConditionalOnMissingClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* @author Marcin Grzejszczak
|
||||
*/
|
||||
@Configuration
|
||||
@ConditionalOnProperty(value="spring.sleuth.metrics.enabled", matchIfMissing=true)
|
||||
@EnableConfigurationProperties
|
||||
public class TraceMetricsAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public SleuthMetricProperties sleuthMetricProperties() {
|
||||
return new SleuthMetricProperties();
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@ConditionalOnClass(CounterService.class)
|
||||
@ConditionalOnMissingBean(SpanReporterService.class)
|
||||
protected static class CounterServiceSpanReporterConfig {
|
||||
@Bean
|
||||
@ConditionalOnBean(CounterService.class)
|
||||
public SpanReporterService spanReporterCounterService(CounterService counterService,
|
||||
SleuthMetricProperties sleuthMetricProperties) {
|
||||
return new CounterServiceBasedSpanReporterService(sleuthMetricProperties.getSpan().getAcceptedName(),
|
||||
sleuthMetricProperties.getSpan().getDroppedName(), counterService);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(CounterService.class)
|
||||
public SpanReporterService noOpSpanReporterCounterService() {
|
||||
return new NoOpSpanReporterService();
|
||||
}
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingClass("org.springframework.boot.actuate.metrics.CounterService")
|
||||
@ConditionalOnMissingBean(SpanReporterService.class)
|
||||
public SpanReporterService noOpSpanReporterCounterService() {
|
||||
return new NoOpSpanReporterService();
|
||||
}
|
||||
}
|
||||
@@ -26,8 +26,8 @@ import org.springframework.cloud.sleuth.Tracer;
|
||||
import org.springframework.cloud.sleuth.event.SpanAcquiredEvent;
|
||||
import org.springframework.cloud.sleuth.event.SpanContinuedEvent;
|
||||
import org.springframework.cloud.sleuth.event.SpanReleasedEvent;
|
||||
import org.springframework.cloud.sleuth.instrument.async.TraceCallable;
|
||||
import org.springframework.cloud.sleuth.instrument.async.TraceRunnable;
|
||||
import org.springframework.cloud.sleuth.TraceCallable;
|
||||
import org.springframework.cloud.sleuth.TraceRunnable;
|
||||
import org.springframework.cloud.sleuth.util.ExceptionUtils;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
# Auto Configuration
|
||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||
org.springframework.cloud.sleuth.autoconfig.TraceAutoConfiguration,\
|
||||
org.springframework.cloud.sleuth.metric.TraceMetricsAutoConfiguration,\
|
||||
org.springframework.cloud.sleuth.log.SleuthLogAutoConfiguration,\
|
||||
org.springframework.cloud.sleuth.instrument.messaging.TraceSpringIntegrationAutoConfiguration,\
|
||||
org.springframework.cloud.sleuth.instrument.websocket.TraceWebSocketAutoConfiguration,\
|
||||
org.springframework.cloud.sleuth.instrument.messaging.websocket.TraceWebSocketAutoConfiguration,\
|
||||
org.springframework.cloud.sleuth.instrument.async.AsyncCustomAutoConfiguration,\
|
||||
org.springframework.cloud.sleuth.instrument.async.AsyncDefaultAutoConfiguration,\
|
||||
org.springframework.cloud.sleuth.instrument.hystrix.SleuthHystrixAutoConfiguration,\
|
||||
|
||||
@@ -13,6 +13,7 @@ import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.springframework.cloud.sleuth.DefaultSpanNamer;
|
||||
import org.springframework.cloud.sleuth.Span;
|
||||
import org.springframework.cloud.sleuth.SpanName;
|
||||
import org.springframework.cloud.sleuth.TraceCallable;
|
||||
import org.springframework.cloud.sleuth.Tracer;
|
||||
import org.springframework.cloud.sleuth.sampler.AlwaysSampler;
|
||||
import org.springframework.cloud.sleuth.trace.DefaultTracer;
|
||||
|
||||
@@ -13,6 +13,7 @@ import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.springframework.cloud.sleuth.DefaultSpanNamer;
|
||||
import org.springframework.cloud.sleuth.Span;
|
||||
import org.springframework.cloud.sleuth.SpanName;
|
||||
import org.springframework.cloud.sleuth.TraceRunnable;
|
||||
import org.springframework.cloud.sleuth.Tracer;
|
||||
import org.springframework.cloud.sleuth.sampler.AlwaysSampler;
|
||||
import org.springframework.cloud.sleuth.trace.DefaultTracer;
|
||||
|
||||
@@ -18,7 +18,7 @@ import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.springframework.cloud.sleuth.Span;
|
||||
import org.springframework.cloud.sleuth.SpanNamer;
|
||||
import org.springframework.cloud.sleuth.Tracer;
|
||||
import org.springframework.cloud.sleuth.instrument.TraceKeys;
|
||||
import org.springframework.cloud.sleuth.TraceKeys;
|
||||
import org.springframework.cloud.sleuth.sampler.AlwaysSampler;
|
||||
import org.springframework.cloud.sleuth.trace.DefaultTracer;
|
||||
import org.springframework.cloud.sleuth.trace.TestSpanContextHolder;
|
||||
@@ -41,7 +41,7 @@ public class TraceableExecutorServiceTests {
|
||||
@Before
|
||||
public void setup() {
|
||||
this.tracer = new DefaultTracer(new AlwaysSampler(), new Random(), this.publisher,
|
||||
spanNamer);
|
||||
this.spanNamer);
|
||||
this.traceManagerableExecutorService = new TraceableExecutorService(this.executorService,
|
||||
this.tracer, new TraceKeys(), this.spanNamer);
|
||||
TestSpanContextHolder.removeCurrentSpan();
|
||||
|
||||
@@ -9,7 +9,7 @@ import org.mockito.Mockito;
|
||||
import org.springframework.cloud.sleuth.DefaultSpanNamer;
|
||||
import org.springframework.cloud.sleuth.Span;
|
||||
import org.springframework.cloud.sleuth.Tracer;
|
||||
import org.springframework.cloud.sleuth.instrument.TraceKeys;
|
||||
import org.springframework.cloud.sleuth.TraceKeys;
|
||||
import org.springframework.cloud.sleuth.sampler.AlwaysSampler;
|
||||
import org.springframework.cloud.sleuth.trace.DefaultTracer;
|
||||
import org.springframework.cloud.sleuth.trace.TestSpanContextHolder;
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.springframework.cloud.sleuth.instrument.messaging;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.cloud.sleuth.Span;
|
||||
import org.springframework.cloud.sleuth.instrument.TraceKeys;
|
||||
import org.springframework.cloud.sleuth.TraceKeys;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.simp.SimpMessageHeaderAccessor;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
|
||||
@@ -13,7 +13,7 @@ import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.cloud.sleuth.Span;
|
||||
import org.springframework.cloud.sleuth.Tracer;
|
||||
import org.springframework.cloud.sleuth.instrument.DefaultTestAutoConfiguration;
|
||||
import org.springframework.cloud.sleuth.instrument.TraceKeys;
|
||||
import org.springframework.cloud.sleuth.TraceKeys;
|
||||
import org.springframework.cloud.sleuth.instrument.web.common.AbstractMvcIntegrationTest;
|
||||
import org.springframework.cloud.sleuth.sampler.AlwaysSampler;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@@ -16,7 +16,7 @@ import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.cloud.sleuth.Span;
|
||||
import org.springframework.cloud.sleuth.Tracer;
|
||||
import org.springframework.cloud.sleuth.instrument.DefaultTestAutoConfiguration;
|
||||
import org.springframework.cloud.sleuth.instrument.TraceKeys;
|
||||
import org.springframework.cloud.sleuth.TraceKeys;
|
||||
import org.springframework.cloud.sleuth.instrument.web.common.AbstractMvcIntegrationTest;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.junit.Test;
|
||||
import org.springframework.cloud.sleuth.DefaultSpanNamer;
|
||||
import org.springframework.cloud.sleuth.Span;
|
||||
import org.springframework.cloud.sleuth.Tracer;
|
||||
import org.springframework.cloud.sleuth.instrument.TraceKeys;
|
||||
import org.springframework.cloud.sleuth.TraceKeys;
|
||||
import org.springframework.cloud.sleuth.sampler.AlwaysSampler;
|
||||
import org.springframework.cloud.sleuth.trace.DefaultTracer;
|
||||
import org.springframework.cloud.sleuth.trace.TestSpanContextHolder;
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.springframework.cloud.sleuth.DefaultSpanNamer;
|
||||
import org.springframework.cloud.sleuth.Sampler;
|
||||
import org.springframework.cloud.sleuth.Span;
|
||||
import org.springframework.cloud.sleuth.Tracer;
|
||||
import org.springframework.cloud.sleuth.instrument.TraceKeys;
|
||||
import org.springframework.cloud.sleuth.TraceKeys;
|
||||
import org.springframework.cloud.sleuth.sampler.AlwaysSampler;
|
||||
import org.springframework.cloud.sleuth.sampler.NeverSampler;
|
||||
import org.springframework.cloud.sleuth.trace.DefaultTracer;
|
||||
|
||||
@@ -3,7 +3,7 @@ package org.springframework.cloud.sleuth.instrument.web.common;
|
||||
import org.junit.Before;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cloud.sleuth.Tracer;
|
||||
import org.springframework.cloud.sleuth.instrument.TraceKeys;
|
||||
import org.springframework.cloud.sleuth.TraceKeys;
|
||||
import org.springframework.cloud.sleuth.instrument.web.TraceFilter;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.web.servlet.setup.DefaultMockMvcBuilder;
|
||||
|
||||
@@ -8,7 +8,7 @@ import org.springframework.cloud.sleuth.Sampler;
|
||||
import org.springframework.cloud.sleuth.Span;
|
||||
import org.springframework.cloud.sleuth.Tracer;
|
||||
import org.springframework.cloud.sleuth.event.ArrayListSpanAccumulator;
|
||||
import org.springframework.cloud.sleuth.instrument.TraceKeys;
|
||||
import org.springframework.cloud.sleuth.TraceKeys;
|
||||
import org.springframework.cloud.sleuth.instrument.web.TraceFilter;
|
||||
import org.springframework.cloud.sleuth.instrument.web.common.AbstractMvcIntegrationTest;
|
||||
import org.springframework.cloud.sleuth.sampler.AlwaysSampler;
|
||||
|
||||
@@ -39,74 +39,74 @@ public class Slf4jSpanListenerTest {
|
||||
Span spanWithNameNotToBeExcluded = Span.builder().name("Aspect").build();
|
||||
String nameExcludingPattern = "^.*Hystrix.*$";
|
||||
Logger log = Mockito.mock(Logger.class);
|
||||
Slf4jSpanListener slf4jSpanListener = new Slf4jSpanListener(nameExcludingPattern, log);
|
||||
Slf4jSpanListener slf4jSpanListener = new Slf4jSpanListener(this.nameExcludingPattern, this.log);
|
||||
|
||||
@Test
|
||||
public void should_log_when_start_event_arrived_and_pattern_doesnt_match_span_name() throws Exception {
|
||||
slf4jSpanListener.start(new SpanAcquiredEvent(this, spanWithNameNotToBeExcluded,
|
||||
spanWithNameNotToBeExcluded));
|
||||
this.slf4jSpanListener.start(new SpanAcquiredEvent(this, this.spanWithNameNotToBeExcluded,
|
||||
this.spanWithNameNotToBeExcluded));
|
||||
|
||||
then(log).should(times(2)).trace(anyString(), anyList());
|
||||
then(this.log).should(times(2)).trace(anyString(), anyList());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_log_once_when_start_event_arrived_and_pattern_matches_only_parent_span_name() throws Exception {
|
||||
slf4jSpanListener.start(new SpanAcquiredEvent(this, spanWithNameToBeExcluded,
|
||||
spanWithNameNotToBeExcluded));
|
||||
this.slf4jSpanListener.start(new SpanAcquiredEvent(this, this.spanWithNameToBeExcluded,
|
||||
this.spanWithNameNotToBeExcluded));
|
||||
|
||||
then(log).should().trace(anyString(), anyList());
|
||||
then(this.log).should().trace(anyString(), anyList());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_log_when_continue_event_arrived_and_pattern_doesnt_match_span_name() throws Exception {
|
||||
slf4jSpanListener.continued(new SpanContinuedEvent(this,
|
||||
spanWithNameNotToBeExcluded));
|
||||
this.slf4jSpanListener.continued(new SpanContinuedEvent(this,
|
||||
this.spanWithNameNotToBeExcluded));
|
||||
|
||||
then(log).should().trace(anyString(), anyList());
|
||||
then(this.log).should().trace(anyString(), anyList());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_not_log_when_continue_event_arrived_and_pattern_matches_name() throws Exception {
|
||||
slf4jSpanListener.continued(new SpanContinuedEvent(this, spanWithNameToBeExcluded));
|
||||
this.slf4jSpanListener.continued(new SpanContinuedEvent(this, this.spanWithNameToBeExcluded));
|
||||
|
||||
then(log).should(never()).trace(anyString(), anyList());
|
||||
then(this.log).should(never()).trace(anyString(), anyList());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_log_when_close_event_arrived_and_pattern_doesnt_match_span_name() throws Exception {
|
||||
slf4jSpanListener.stop(new SpanReleasedEvent(this, spanWithNameNotToBeExcluded));
|
||||
this.slf4jSpanListener.stop(new SpanReleasedEvent(this, this.spanWithNameNotToBeExcluded));
|
||||
|
||||
then(log).should().trace(anyString(), anyList());
|
||||
then(this.log).should().trace(anyString(), anyList());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_log_both_spans_when_their_names_dont_match_pattern() throws Exception {
|
||||
slf4jSpanListener.stop(new SpanReleasedEvent(this, spanWithNameNotToBeExcluded,
|
||||
spanWithNameNotToBeExcluded));
|
||||
this.slf4jSpanListener.stop(new SpanReleasedEvent(this, this.spanWithNameNotToBeExcluded,
|
||||
this.spanWithNameNotToBeExcluded));
|
||||
|
||||
then(log).should(times(2)).trace(anyString(), anyList());
|
||||
then(this.log).should(times(2)).trace(anyString(), anyList());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_not_log_any_spans_if_both_match_pattern() throws Exception {
|
||||
slf4jSpanListener.stop(new SpanReleasedEvent(this, spanWithNameToBeExcluded,
|
||||
spanWithNameToBeExcluded));
|
||||
this.slf4jSpanListener.stop(new SpanReleasedEvent(this, this.spanWithNameToBeExcluded,
|
||||
this.spanWithNameToBeExcluded));
|
||||
|
||||
then(log).should(never()).trace(anyString(), anyList());
|
||||
then(this.log).should(never()).trace(anyString(), anyList());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_log_only_current_span_if_parent_span_name_matches_pattern() throws Exception {
|
||||
slf4jSpanListener.stop(new SpanReleasedEvent(this, spanWithNameNotToBeExcluded,
|
||||
spanWithNameToBeExcluded));
|
||||
this.slf4jSpanListener.stop(new SpanReleasedEvent(this, this.spanWithNameNotToBeExcluded,
|
||||
this.spanWithNameToBeExcluded));
|
||||
|
||||
then(log).should().trace(anyString(), anyList());
|
||||
then(this.log).should().trace(anyString(), anyList());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_log_only_current_span_if_there_is_no_parent() throws Exception {
|
||||
slf4jSpanListener.stop(new SpanReleasedEvent(this, spanWithNameNotToBeExcluded));
|
||||
this.slf4jSpanListener.stop(new SpanReleasedEvent(this, this.spanWithNameNotToBeExcluded));
|
||||
|
||||
then(log).should().trace(anyString(), anyList());
|
||||
then(this.log).should().trace(anyString(), anyList());
|
||||
}
|
||||
}
|
||||
@@ -41,6 +41,7 @@ import org.springframework.cloud.sleuth.event.ClientReceivedEvent;
|
||||
import org.springframework.cloud.sleuth.event.ClientSentEvent;
|
||||
import org.springframework.cloud.sleuth.event.ServerReceivedEvent;
|
||||
import org.springframework.cloud.sleuth.event.ServerSentEvent;
|
||||
import org.springframework.cloud.sleuth.metric.TraceMetricsAutoConfiguration;
|
||||
import org.springframework.cloud.sleuth.sampler.AlwaysSampler;
|
||||
import org.springframework.cloud.sleuth.stream.StreamSpanListenerTests.TestConfiguration;
|
||||
import org.springframework.cloud.stream.config.ChannelBindingAutoConfiguration;
|
||||
@@ -116,8 +117,9 @@ public class StreamSpanListenerTests {
|
||||
|
||||
@Configuration
|
||||
@Import({ ZipkinTestConfiguration.class, SleuthStreamAutoConfiguration.class,
|
||||
TestSupportBinderAutoConfiguration.class, ChannelBindingAutoConfiguration.class,
|
||||
TraceAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class })
|
||||
TraceMetricsAutoConfiguration.class, TestSupportBinderAutoConfiguration.class,
|
||||
ChannelBindingAutoConfiguration.class, TraceAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class })
|
||||
protected static class TestConfiguration {}
|
||||
|
||||
@Configuration
|
||||
|
||||
Reference in New Issue
Block a user