Removes deprecations; fixes #621
This commit is contained in:
@@ -19,6 +19,8 @@ package org.springframework.cloud.sleuth;
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -32,9 +34,6 @@ import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Class for gathering and reporting statistics about a block of execution.
|
||||
* <p>
|
||||
@@ -171,7 +170,10 @@ public class Span implements SpanContext {
|
||||
* Creates a new span that still tracks tags and logs of the current span. This is
|
||||
* crucial when continuing spans since the changes in those collections done in the
|
||||
* continued span need to be reflected until the span gets closed.
|
||||
*
|
||||
* @deprecated - use {@link SpanBuilder}
|
||||
*/
|
||||
@Deprecated
|
||||
public Span(Span current, Span savedSpan) {
|
||||
this.begin = current.getBegin();
|
||||
this.end = current.getEnd();
|
||||
@@ -191,21 +193,13 @@ public class Span implements SpanContext {
|
||||
this.savedSpan = savedSpan;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated please use {@link SpanBuilder}
|
||||
*/
|
||||
@Deprecated
|
||||
public Span(long begin, long end, String name, long traceId, List<Long> parents,
|
||||
Span(long begin, long end, String name, long traceId, List<Long> parents,
|
||||
long spanId, boolean remote, boolean exportable, String processId) {
|
||||
this(begin, end, name, traceId, parents, spanId, remote, exportable, processId,
|
||||
null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated please use {@link SpanBuilder}
|
||||
*/
|
||||
@Deprecated
|
||||
public Span(long begin, long end, String name, long traceId, List<Long> parents,
|
||||
Span(long begin, long end, String name, long traceId, List<Long> parents,
|
||||
long spanId, boolean remote, boolean exportable, String processId,
|
||||
Span savedSpan) {
|
||||
this(new SpanBuilder()
|
||||
@@ -274,18 +268,6 @@ public class Span implements SpanContext {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the total amount of time elapsed since start was called, if running, or
|
||||
* difference between stop and start
|
||||
*
|
||||
* @deprecated use {@link #getAccumulatedMicros()} as it is more precise.
|
||||
*/
|
||||
@Deprecated
|
||||
@JsonIgnore
|
||||
public synchronized long getAccumulatedMillis() {
|
||||
return getAccumulatedMicros() / 1000;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the total amount of time elapsed since start was called, if running, or
|
||||
* difference between stop and start, in microseconds.
|
||||
@@ -766,6 +748,9 @@ public class Span implements SpanContext {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link Span.SpanBuilder} from the {@link Span}.
|
||||
*/
|
||||
public Span.SpanBuilder from(Span span) {
|
||||
return begin(span.begin).end(span.end).name(span.name)
|
||||
.traceIdHigh(span.traceIdHigh).traceId(span.traceId)
|
||||
@@ -774,6 +759,11 @@ public class Span implements SpanContext {
|
||||
.processId(span.processId).savedSpan(span.savedSpan);
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a span. All collections lik baggage / tags / logs are *copied*, not continued.
|
||||
* In other words if you add a tag to the input {@link Span}, the created span
|
||||
* will not reflect that change.
|
||||
*/
|
||||
public Span build() {
|
||||
return new Span(this);
|
||||
}
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013-2017 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.instrument.async;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* Trace Callable that continues a span instead of creating a new one. Upon completion
|
||||
* the span is not closed - it gets {@link Tracer#detach(Span) detached}.
|
||||
*
|
||||
* @author Marcin Grzejszczak
|
||||
* @since 1.0.0
|
||||
* @deprecated as of 1.2 in favor of {@link SpanContinuingTraceCallable}
|
||||
*/
|
||||
@Deprecated
|
||||
public class TraceContinuingCallable<V> extends TraceCallable<V> implements Callable<V> {
|
||||
|
||||
public TraceContinuingCallable(Tracer tracer, SpanNamer spanNamer, Callable<V> delegate) {
|
||||
super(tracer, spanNamer, delegate);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Span startSpan() {
|
||||
return getTracer().continueSpan(getParent());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void close(Span span) {
|
||||
if (getTracer().isTracing()) {
|
||||
getTracer().detach(span);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,9 @@
|
||||
package org.springframework.cloud.sleuth.instrument.messaging;
|
||||
|
||||
import java.lang.invoke.MethodHandles;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.cloud.sleuth.ErrorParser;
|
||||
import org.springframework.cloud.sleuth.ExceptionMessageErrorParser;
|
||||
import org.springframework.cloud.sleuth.Span;
|
||||
import org.springframework.cloud.sleuth.SpanTextMap;
|
||||
import org.springframework.cloud.sleuth.TraceKeys;
|
||||
@@ -19,6 +16,8 @@ import org.springframework.messaging.support.ChannelInterceptorAdapter;
|
||||
import org.springframework.messaging.support.ExecutorChannelInterceptor;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
import java.lang.invoke.MethodHandles;
|
||||
|
||||
/**
|
||||
* Abstraction over classes related to channel intercepting
|
||||
*
|
||||
@@ -46,17 +45,6 @@ abstract class AbstractTraceChannelInterceptor extends ChannelInterceptorAdapter
|
||||
private ErrorParser errorParser;
|
||||
private BeanFactory beanFactory;
|
||||
|
||||
@Deprecated
|
||||
protected AbstractTraceChannelInterceptor(Tracer tracer, TraceKeys traceKeys,
|
||||
MessagingSpanTextMapExtractor spanExtractor,
|
||||
MessagingSpanTextMapInjector spanInjector) {
|
||||
this.tracer = tracer;
|
||||
this.traceKeys = traceKeys;
|
||||
this.spanExtractor = spanExtractor;
|
||||
this.spanInjector = spanInjector;
|
||||
this.errorParser = new ExceptionMessageErrorParser();
|
||||
}
|
||||
|
||||
protected AbstractTraceChannelInterceptor(BeanFactory beanFactory) {
|
||||
this.beanFactory = beanFactory;
|
||||
}
|
||||
|
||||
@@ -17,8 +17,6 @@
|
||||
package org.springframework.cloud.sleuth.instrument.messaging;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.cloud.sleuth.TraceKeys;
|
||||
import org.springframework.cloud.sleuth.Tracer;
|
||||
import org.springframework.integration.channel.ChannelInterceptorAware;
|
||||
import org.springframework.integration.channel.interceptor.VetoCapableInterceptor;
|
||||
import org.springframework.messaging.support.ChannelInterceptor;
|
||||
@@ -29,14 +27,7 @@ import org.springframework.messaging.support.ChannelInterceptor;
|
||||
*/
|
||||
class IntegrationTraceChannelInterceptor extends TraceChannelInterceptor implements VetoCapableInterceptor {
|
||||
|
||||
@Deprecated
|
||||
public IntegrationTraceChannelInterceptor(Tracer tracer, TraceKeys traceKeys,
|
||||
MessagingSpanTextMapExtractor spanExtractor,
|
||||
MessagingSpanTextMapInjector spanInjector) {
|
||||
super(tracer, traceKeys, spanExtractor, spanInjector);
|
||||
}
|
||||
|
||||
public IntegrationTraceChannelInterceptor(BeanFactory beanFactory) {
|
||||
IntegrationTraceChannelInterceptor(BeanFactory beanFactory) {
|
||||
super(beanFactory);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,8 +19,6 @@ package org.springframework.cloud.sleuth.instrument.messaging;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.cloud.sleuth.Log;
|
||||
import org.springframework.cloud.sleuth.Span;
|
||||
import org.springframework.cloud.sleuth.TraceKeys;
|
||||
import org.springframework.cloud.sleuth.Tracer;
|
||||
import org.springframework.cloud.sleuth.sampler.NeverSampler;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
@@ -38,13 +36,6 @@ import org.springframework.messaging.support.MessageHeaderAccessor;
|
||||
*/
|
||||
public class TraceChannelInterceptor extends AbstractTraceChannelInterceptor {
|
||||
|
||||
@Deprecated
|
||||
public TraceChannelInterceptor(Tracer tracer, TraceKeys traceKeys,
|
||||
MessagingSpanTextMapExtractor spanExtractor,
|
||||
MessagingSpanTextMapInjector spanInjector) {
|
||||
super(tracer, traceKeys, spanExtractor, spanInjector);
|
||||
}
|
||||
|
||||
public TraceChannelInterceptor(BeanFactory beanFactory) {
|
||||
super(beanFactory);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.springframework.cloud.sleuth.instrument.messaging.websocket;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
@@ -36,6 +37,8 @@ import org.springframework.web.socket.config.annotation.StompEndpointRegistry;
|
||||
public class TraceWebSocketAutoConfiguration
|
||||
extends AbstractWebSocketMessageBrokerConfigurer {
|
||||
|
||||
@Autowired
|
||||
BeanFactory beanFactory;
|
||||
@Autowired
|
||||
Tracer tracer;
|
||||
@Autowired
|
||||
@@ -52,13 +55,11 @@ public class TraceWebSocketAutoConfiguration
|
||||
|
||||
@Override
|
||||
public void configureClientOutboundChannel(ChannelRegistration registration) {
|
||||
registration.setInterceptors(new TraceChannelInterceptor(this.tracer,
|
||||
this.traceKeys, this.spanExtractor, this.spanInjector));
|
||||
registration.setInterceptors(new TraceChannelInterceptor(this.beanFactory));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configureClientInboundChannel(ChannelRegistration registration) {
|
||||
registration.setInterceptors(new TraceChannelInterceptor(this.tracer,
|
||||
this.traceKeys, this.spanExtractor, this.spanInjector));
|
||||
registration.setInterceptors(new TraceChannelInterceptor(this.beanFactory));
|
||||
}
|
||||
}
|
||||
@@ -32,7 +32,6 @@ import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.cloud.sleuth.ErrorParser;
|
||||
import org.springframework.cloud.sleuth.ExceptionMessageErrorParser;
|
||||
import org.springframework.cloud.sleuth.Span;
|
||||
import org.springframework.cloud.sleuth.SpanReporter;
|
||||
import org.springframework.cloud.sleuth.TraceKeys;
|
||||
@@ -91,12 +90,6 @@ public class TraceFilter extends GenericFilterBean {
|
||||
protected static final String TRACE_CLOSE_SPAN_REQUEST_ATTR = TraceFilter.class.getName()
|
||||
+ ".CLOSE_SPAN";
|
||||
|
||||
/**
|
||||
* @deprecated please use {@link SleuthWebProperties#DEFAULT_SKIP_PATTERN}
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String DEFAULT_SKIP_PATTERN = SleuthWebProperties.DEFAULT_SKIP_PATTERN;
|
||||
|
||||
private Tracer tracer;
|
||||
private TraceKeys traceKeys;
|
||||
private Pattern skipPattern;
|
||||
@@ -108,27 +101,6 @@ public class TraceFilter extends GenericFilterBean {
|
||||
|
||||
private UrlPathHelper urlPathHelper = new UrlPathHelper();
|
||||
|
||||
@Deprecated
|
||||
public TraceFilter(Tracer tracer, TraceKeys traceKeys, SpanReporter spanReporter,
|
||||
HttpSpanExtractor spanExtractor,
|
||||
HttpTraceKeysInjector httpTraceKeysInjector) {
|
||||
this(tracer, traceKeys, Pattern.compile(SleuthWebProperties.DEFAULT_SKIP_PATTERN), spanReporter,
|
||||
spanExtractor, httpTraceKeysInjector);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public TraceFilter(Tracer tracer, TraceKeys traceKeys, Pattern skipPattern,
|
||||
SpanReporter spanReporter, HttpSpanExtractor spanExtractor,
|
||||
HttpTraceKeysInjector httpTraceKeysInjector) {
|
||||
this.tracer = tracer;
|
||||
this.traceKeys = traceKeys;
|
||||
this.skipPattern = skipPattern;
|
||||
this.spanReporter = spanReporter;
|
||||
this.spanExtractor = spanExtractor;
|
||||
this.httpTraceKeysInjector = httpTraceKeysInjector;
|
||||
this.errorParser = new ExceptionMessageErrorParser();
|
||||
}
|
||||
|
||||
public TraceFilter(BeanFactory beanFactory) {
|
||||
this(beanFactory, Pattern.compile(SleuthWebProperties.DEFAULT_SKIP_PATTERN));
|
||||
}
|
||||
|
||||
@@ -16,18 +16,12 @@
|
||||
|
||||
package org.springframework.cloud.sleuth.instrument.web;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.concurrent.Callable;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Pointcut;
|
||||
import org.springframework.cloud.sleuth.ErrorParser;
|
||||
import org.springframework.cloud.sleuth.ExceptionMessageErrorParser;
|
||||
import org.springframework.cloud.sleuth.Span;
|
||||
import org.springframework.cloud.sleuth.SpanNamer;
|
||||
import org.springframework.cloud.sleuth.TraceKeys;
|
||||
@@ -35,6 +29,11 @@ import org.springframework.cloud.sleuth.Tracer;
|
||||
import org.springframework.cloud.sleuth.instrument.async.SpanContinuingTraceCallable;
|
||||
import org.springframework.web.context.request.async.WebAsyncTask;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
/**
|
||||
* Aspect that adds tracing to
|
||||
* <p/>
|
||||
@@ -79,14 +78,6 @@ public class TraceWebAspect {
|
||||
private final TraceKeys traceKeys;
|
||||
private final ErrorParser errorParser;
|
||||
|
||||
@Deprecated
|
||||
public TraceWebAspect(Tracer tracer, SpanNamer spanNamer, TraceKeys traceKeys) {
|
||||
this.tracer = tracer;
|
||||
this.spanNamer = spanNamer;
|
||||
this.traceKeys = traceKeys;
|
||||
this.errorParser = new ExceptionMessageErrorParser();
|
||||
}
|
||||
|
||||
public TraceWebAspect(Tracer tracer, SpanNamer spanNamer, TraceKeys traceKeys,
|
||||
ErrorParser errorParser) {
|
||||
this.tracer = tracer;
|
||||
|
||||
@@ -16,16 +16,9 @@
|
||||
|
||||
package org.springframework.cloud.sleuth.instrument.web.client;
|
||||
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.net.URI;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.cloud.sleuth.ErrorParser;
|
||||
import org.springframework.cloud.sleuth.ExceptionMessageErrorParser;
|
||||
import org.springframework.cloud.sleuth.Span;
|
||||
import org.springframework.cloud.sleuth.Tracer;
|
||||
import org.springframework.core.task.AsyncListenableTaskExecutor;
|
||||
@@ -42,6 +35,12 @@ import org.springframework.web.client.ResponseExtractor;
|
||||
import org.springframework.web.client.RestClientException;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.net.URI;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
/**
|
||||
* An {@link AsyncRestTemplate} that closes started spans when a response has been
|
||||
* successfully received.
|
||||
@@ -55,44 +54,6 @@ public class TraceAsyncRestTemplate extends AsyncRestTemplate {
|
||||
private final Tracer tracer;
|
||||
private final ErrorParser errorParser;
|
||||
|
||||
@Deprecated
|
||||
public TraceAsyncRestTemplate(Tracer tracer) {
|
||||
super();
|
||||
this.tracer = tracer;
|
||||
this.errorParser = new ExceptionMessageErrorParser();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public TraceAsyncRestTemplate(AsyncListenableTaskExecutor taskExecutor, Tracer tracer) {
|
||||
super(taskExecutor);
|
||||
this.tracer = tracer;
|
||||
this.errorParser = new ExceptionMessageErrorParser();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public TraceAsyncRestTemplate(AsyncClientHttpRequestFactory asyncRequestFactory,
|
||||
Tracer tracer) {
|
||||
super(asyncRequestFactory);
|
||||
this.tracer = tracer;
|
||||
this.errorParser = new ExceptionMessageErrorParser();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public TraceAsyncRestTemplate(AsyncClientHttpRequestFactory asyncRequestFactory,
|
||||
ClientHttpRequestFactory syncRequestFactory, Tracer tracer) {
|
||||
super(asyncRequestFactory, syncRequestFactory);
|
||||
this.tracer = tracer;
|
||||
this.errorParser = new ExceptionMessageErrorParser();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public TraceAsyncRestTemplate(AsyncClientHttpRequestFactory requestFactory,
|
||||
RestTemplate restTemplate, Tracer tracer) {
|
||||
super(requestFactory, restTemplate);
|
||||
this.tracer = tracer;
|
||||
this.errorParser = new ExceptionMessageErrorParser();
|
||||
}
|
||||
|
||||
public TraceAsyncRestTemplate(Tracer tracer, ErrorParser errorParser) {
|
||||
super();
|
||||
this.tracer = tracer;
|
||||
|
||||
@@ -16,10 +16,7 @@
|
||||
|
||||
package org.springframework.cloud.sleuth.instrument.web.client;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.springframework.cloud.sleuth.ErrorParser;
|
||||
import org.springframework.cloud.sleuth.ExceptionMessageErrorParser;
|
||||
import org.springframework.cloud.sleuth.Tracer;
|
||||
import org.springframework.cloud.sleuth.instrument.web.HttpSpanInjector;
|
||||
import org.springframework.cloud.sleuth.instrument.web.HttpTraceKeysInjector;
|
||||
@@ -28,6 +25,8 @@ import org.springframework.http.client.ClientHttpRequestExecution;
|
||||
import org.springframework.http.client.ClientHttpRequestInterceptor;
|
||||
import org.springframework.http.client.ClientHttpResponse;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Interceptor that verifies whether the trance and span id has been set on the request
|
||||
* and sets them if one or both of them are missing.
|
||||
@@ -43,13 +42,6 @@ public class TraceRestTemplateInterceptor extends AbstractTraceHttpRequestInterc
|
||||
|
||||
private final ErrorParser errorParser;
|
||||
|
||||
@Deprecated
|
||||
public TraceRestTemplateInterceptor(Tracer tracer, HttpSpanInjector spanInjector,
|
||||
HttpTraceKeysInjector httpTraceKeysInjector) {
|
||||
super(tracer, spanInjector, httpTraceKeysInjector);
|
||||
this.errorParser = new ExceptionMessageErrorParser();
|
||||
}
|
||||
|
||||
public TraceRestTemplateInterceptor(Tracer tracer, HttpSpanInjector spanInjector,
|
||||
HttpTraceKeysInjector httpTraceKeysInjector, ErrorParser errorParser) {
|
||||
super(tracer, spanInjector, httpTraceKeysInjector);
|
||||
|
||||
@@ -22,6 +22,7 @@ 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.ErrorParser;
|
||||
import org.springframework.cloud.sleuth.instrument.web.HttpSpanInjector;
|
||||
import org.springframework.cloud.sleuth.Tracer;
|
||||
import org.springframework.cloud.sleuth.instrument.web.HttpTraceKeysInjector;
|
||||
@@ -86,8 +87,8 @@ public class TraceWebAsyncClientAutoConfiguration {
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
@ConditionalOnProperty(value = "spring.sleuth.web.async.client.template.enabled", matchIfMissing = true)
|
||||
public AsyncRestTemplate traceAsyncRestTemplate() {
|
||||
return new TraceAsyncRestTemplate(traceAsyncClientHttpRequestFactory(), this.tracer);
|
||||
public AsyncRestTemplate traceAsyncRestTemplate(ErrorParser errorParser) {
|
||||
return new TraceAsyncRestTemplate(traceAsyncClientHttpRequestFactory(), this.tracer, errorParser);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -44,8 +44,6 @@ public class DefaultTracer implements Tracer {
|
||||
|
||||
private static final Log log = LogFactory.getLog(MethodHandles.lookup().lookupClass());
|
||||
|
||||
private static final int MAX_CHARS_IN_SPAN_NAME = 50;
|
||||
|
||||
private final Sampler defaultSampler;
|
||||
|
||||
private final Random random;
|
||||
@@ -60,18 +58,6 @@ public class DefaultTracer implements Tracer {
|
||||
|
||||
private final boolean traceId128;
|
||||
|
||||
@Deprecated
|
||||
public DefaultTracer(Sampler defaultSampler, Random random, SpanNamer spanNamer,
|
||||
SpanLogger spanLogger, SpanReporter spanReporter) {
|
||||
this(defaultSampler, random, spanNamer, spanLogger, spanReporter, false);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public DefaultTracer(Sampler defaultSampler, Random random, SpanNamer spanNamer,
|
||||
SpanLogger spanLogger, SpanReporter spanReporter, boolean traceId128) {
|
||||
this(defaultSampler, random, spanNamer, spanLogger, spanReporter, traceId128, null);
|
||||
}
|
||||
|
||||
public DefaultTracer(Sampler defaultSampler, Random random, SpanNamer spanNamer,
|
||||
SpanLogger spanLogger, SpanReporter spanReporter, TraceKeys traceKeys) {
|
||||
this(defaultSampler, random, spanNamer, spanLogger, spanReporter, false, traceKeys);
|
||||
|
||||
@@ -18,14 +18,13 @@ package org.springframework.cloud.sleuth;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.BDDAssertions.then;
|
||||
import static org.springframework.cloud.sleuth.assertions.SleuthAssertions.assertThat;
|
||||
import static org.springframework.cloud.sleuth.assertions.SleuthAssertions.then;
|
||||
|
||||
/**
|
||||
* @author Marcin Grzejszczak
|
||||
@@ -263,6 +262,17 @@ public class SpanTests {
|
||||
assertThat(builtSpan).isEqualTo(span);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_build_a_continued_span_from_provided_span() throws IOException {
|
||||
Span span = builder().tag("foo", "bar").build();
|
||||
Span savedSpan = builder().tag("foo2", "bar2").build();
|
||||
Span builtSpan = new Span(span, savedSpan);
|
||||
|
||||
span.tag("foo2", "bar2");
|
||||
|
||||
assertThat(builtSpan).isEqualTo(span);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_convert_a_span_to_builder() throws IOException {
|
||||
Span.SpanBuilder spanBuilder = builder();
|
||||
|
||||
@@ -27,6 +27,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.cloud.sleuth.ErrorParser;
|
||||
import org.springframework.cloud.sleuth.Tracer;
|
||||
import org.springframework.cloud.sleuth.instrument.web.HttpSpanInjector;
|
||||
import org.springframework.cloud.sleuth.instrument.web.HttpTraceKeysInjector;
|
||||
@@ -81,8 +82,8 @@ public class MultipleAsyncRestTemplateTests {
|
||||
|
||||
@Bean(name = "customAsyncRestTemplate")
|
||||
public AsyncRestTemplate traceAsyncRestTemplate(@Qualifier("customHttpRequestFactoryWrapper")
|
||||
TraceAsyncClientHttpRequestFactoryWrapper wrapper) {
|
||||
return new TraceAsyncRestTemplate(wrapper, this.tracer);
|
||||
TraceAsyncClientHttpRequestFactoryWrapper wrapper, ErrorParser errorParser) {
|
||||
return new TraceAsyncRestTemplate(wrapper, this.tracer, errorParser);
|
||||
}
|
||||
|
||||
@Bean(name = "customHttpRequestFactoryWrapper")
|
||||
|
||||
@@ -16,8 +16,11 @@
|
||||
|
||||
package org.springframework.cloud.sleuth.instrument.hystrix;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.netflix.hystrix.HystrixCommand;
|
||||
import com.netflix.hystrix.HystrixCommandKey;
|
||||
import com.netflix.hystrix.HystrixCommandProperties;
|
||||
import com.netflix.hystrix.HystrixThreadPoolProperties;
|
||||
import com.netflix.hystrix.strategy.HystrixPlugins;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -31,11 +34,7 @@ import org.springframework.cloud.sleuth.sampler.AlwaysSampler;
|
||||
import org.springframework.cloud.sleuth.trace.DefaultTracer;
|
||||
import org.springframework.cloud.sleuth.trace.TestSpanContextHolder;
|
||||
|
||||
import com.netflix.hystrix.HystrixCommand;
|
||||
import com.netflix.hystrix.HystrixCommandKey;
|
||||
import com.netflix.hystrix.HystrixCommandProperties;
|
||||
import com.netflix.hystrix.HystrixThreadPoolProperties;
|
||||
import com.netflix.hystrix.strategy.HystrixPlugins;
|
||||
import java.util.Random;
|
||||
|
||||
import static com.netflix.hystrix.HystrixCommand.Setter.withGroupKey;
|
||||
import static com.netflix.hystrix.HystrixCommandGroupKey.Factory.asKey;
|
||||
@@ -99,7 +98,7 @@ public class TraceCommandTests {
|
||||
@Test
|
||||
public void should_pass_tracing_information_when_using_Hystrix_commands() {
|
||||
Tracer tracer = new DefaultTracer(new AlwaysSampler(), new Random(),
|
||||
new DefaultSpanNamer(), new NoOpSpanLogger(), new NoOpSpanReporter());
|
||||
new DefaultSpanNamer(), new NoOpSpanLogger(), new NoOpSpanReporter(), new TraceKeys());
|
||||
TraceKeys traceKeys = new TraceKeys();
|
||||
HystrixCommand.Setter setter = withGroupKey(asKey("group"))
|
||||
.andCommandKey(HystrixCommandKey.Factory.asKey("command"));
|
||||
|
||||
@@ -16,11 +16,6 @@
|
||||
|
||||
package org.springframework.cloud.sleuth.instrument.web;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Optional;
|
||||
import java.util.Random;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -53,6 +48,11 @@ import org.springframework.mock.web.MockHttpServletResponse;
|
||||
import org.springframework.mock.web.MockServletContext;
|
||||
import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Optional;
|
||||
import java.util.Random;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.MockitoAnnotations.initMocks;
|
||||
import static org.springframework.cloud.sleuth.assertions.SleuthAssertions.assertThat;
|
||||
@@ -83,6 +83,7 @@ public class TraceFilterTests {
|
||||
private MockHttpServletResponse response;
|
||||
private MockFilterChain filterChain;
|
||||
private Sampler sampler = new AlwaysSampler();
|
||||
BeanFactory beanFactory = Mockito.mock(BeanFactory.class);
|
||||
|
||||
@Before
|
||||
public void init() {
|
||||
@@ -260,8 +261,8 @@ public class TraceFilterTests {
|
||||
public void ensuresThatParentSpanIsStoppedWhenReported() throws Exception {
|
||||
this.request = builder().header(Span.SPAN_ID_NAME, PARENT_ID)
|
||||
.header(Span.TRACE_ID_NAME, 20L).buildRequest(new MockServletContext());
|
||||
TraceFilter filter = new TraceFilter(this.tracer, this.traceKeys, spanIsStoppedVeryfingReporter(),
|
||||
this.spanExtractor, this.httpTraceKeysInjector);
|
||||
TraceFilter filter = new TraceFilter(beanFactory());
|
||||
BDDMockito.given(beanFactory.getBean(SpanReporter.class)).willReturn(spanIsStoppedVeryfingReporter());
|
||||
|
||||
filter.doFilter(this.request, this.response, this.filterChain);
|
||||
}
|
||||
@@ -483,7 +484,6 @@ public class TraceFilterTests {
|
||||
}
|
||||
|
||||
private BeanFactory beanFactory() {
|
||||
BeanFactory beanFactory = Mockito.mock(BeanFactory.class);
|
||||
BDDMockito.given(beanFactory.getBean(Tracer.class)).willReturn(this.tracer);
|
||||
BDDMockito.given(beanFactory.getBean(TraceKeys.class)).willReturn(this.traceKeys);
|
||||
BDDMockito.given(beanFactory.getBean(HttpSpanExtractor.class)).willReturn(this.spanExtractor);
|
||||
|
||||
@@ -16,10 +16,6 @@
|
||||
|
||||
package org.springframework.cloud.sleuth.trace;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
@@ -37,6 +33,10 @@ import org.springframework.cloud.sleuth.log.SpanLogger;
|
||||
import org.springframework.cloud.sleuth.sampler.AlwaysSampler;
|
||||
import org.springframework.cloud.sleuth.sampler.NeverSampler;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Mockito.atLeast;
|
||||
import static org.mockito.Mockito.times;
|
||||
@@ -245,7 +245,7 @@ public class DefaultTracerTests {
|
||||
@Test
|
||||
public void shouldNotProduceAWarningMessageWhenThereIsNoSpanInContextAndWeDetachASpan() {
|
||||
DefaultTracer tracer = new DefaultTracer(new AlwaysSampler(), new Random(),
|
||||
this.spanNamer, this.spanLogger, this.spanReporter);
|
||||
this.spanNamer, this.spanLogger, this.spanReporter, new TraceKeys());
|
||||
Span span = Span.builder().name("foo").traceId(1L).spanId(1L).build();
|
||||
|
||||
Span child = tracer.detach(span);
|
||||
|
||||
@@ -38,11 +38,6 @@ public class DiscoveryClientHostLocator implements HostLocator {
|
||||
private final DiscoveryClient client;
|
||||
private final ZipkinProperties zipkinProperties;
|
||||
|
||||
@Deprecated
|
||||
public DiscoveryClientHostLocator(DiscoveryClient client) {
|
||||
this(client, new ZipkinProperties());
|
||||
}
|
||||
|
||||
public DiscoveryClientHostLocator(DiscoveryClient client, ZipkinProperties zipkinProperties) {
|
||||
this.client = client;
|
||||
Assert.notNull(this.client, "client");
|
||||
|
||||
@@ -53,11 +53,6 @@ public class ServerPropertiesHostLocator implements HostLocator {
|
||||
private final ZipkinProperties zipkinProperties;
|
||||
private Integer port; // Lazy assigned
|
||||
|
||||
@Deprecated
|
||||
public ServerPropertiesHostLocator(ServerProperties serverProperties, String appName) {
|
||||
this(serverProperties, appName, new ZipkinProperties(),null);
|
||||
}
|
||||
|
||||
public ServerPropertiesHostLocator(ServerProperties serverProperties, String appName,
|
||||
ZipkinProperties zipkinProperties, InetUtils inetUtils) {
|
||||
this.serverProperties = serverProperties;
|
||||
|
||||
@@ -16,19 +16,9 @@
|
||||
|
||||
package org.springframework.cloud.sleuth.stream;
|
||||
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.cloud.commons.util.IdUtils;
|
||||
import org.springframework.cloud.sleuth.Log;
|
||||
import org.springframework.cloud.sleuth.NoOpSpanAdjuster;
|
||||
import org.springframework.cloud.sleuth.Span;
|
||||
import org.springframework.cloud.sleuth.SpanAdjuster;
|
||||
import org.springframework.cloud.sleuth.SpanReporter;
|
||||
@@ -38,6 +28,14 @@ import org.springframework.integration.annotation.InboundChannelAdapter;
|
||||
import org.springframework.integration.annotation.MessageEndpoint;
|
||||
import org.springframework.integration.annotation.Poller;
|
||||
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
|
||||
/**
|
||||
* A message source for spans. Also handles RPC flavoured annotations.
|
||||
*
|
||||
@@ -66,18 +64,6 @@ public class StreamSpanReporter implements SpanReporter {
|
||||
private final Environment environment;
|
||||
private final List<SpanAdjuster> spanAdjusters;
|
||||
|
||||
@Deprecated
|
||||
public StreamSpanReporter(HostLocator endpointLocator,
|
||||
SpanMetricReporter spanMetricReporter) {
|
||||
this(endpointLocator, spanMetricReporter, null);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public StreamSpanReporter(HostLocator endpointLocator,
|
||||
SpanMetricReporter spanMetricReporter, Environment environment) {
|
||||
this(endpointLocator, spanMetricReporter, environment, Collections.<SpanAdjuster>singletonList(new NoOpSpanAdjuster()));
|
||||
}
|
||||
|
||||
public StreamSpanReporter(HostLocator endpointLocator,
|
||||
SpanMetricReporter spanMetricReporter, Environment environment, List<SpanAdjuster> spanAdjusters) {
|
||||
this.endpointLocator = endpointLocator;
|
||||
|
||||
@@ -16,10 +16,6 @@
|
||||
|
||||
package org.springframework.cloud.sleuth.stream;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
import org.springframework.boot.autoconfigure.web.ServerProperties;
|
||||
@@ -27,14 +23,16 @@ import org.springframework.cloud.commons.util.InetUtils;
|
||||
import org.springframework.cloud.commons.util.InetUtilsProperties;
|
||||
import org.springframework.cloud.sleuth.Span;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class ServerPropertiesHostLocatorTests {
|
||||
|
||||
public static final byte[] ADR1234 = { 1, 2, 3, 4 };
|
||||
|
||||
Span span = new Span(1, 3, "http:name", 1L, Collections.<Long>emptyList(), 2L, true, true,
|
||||
"process");
|
||||
Span span = Span.builder().begin(1).end(3).name("http:name").traceId(1L).spanId(2L).remote(true).exportable(true).processId("process").build();
|
||||
|
||||
@Test
|
||||
public void portDefaultsTo8080() throws UnknownHostException {
|
||||
|
||||
@@ -16,11 +16,6 @@
|
||||
|
||||
package org.springframework.cloud.sleuth.stream;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ArrayBlockingQueue;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
@@ -29,6 +24,12 @@ import org.springframework.cloud.sleuth.SpanAdjuster;
|
||||
import org.springframework.cloud.sleuth.metric.SpanMetricReporter;
|
||||
import org.springframework.mock.env.MockEnvironment;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ArrayBlockingQueue;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
|
||||
@@ -44,7 +45,8 @@ public class StreamSpanReporterTests {
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
this.reporter = new StreamSpanReporter(this.endpointLocator, this.spanMetricReporter, this.mockEnvironment);
|
||||
this.reporter = new StreamSpanReporter(this.endpointLocator, this.spanMetricReporter,
|
||||
this.mockEnvironment, new ArrayList<>());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -79,7 +81,8 @@ public class StreamSpanReporterTests {
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void should_not_append_server_serviceid_when_span_has_rpc_event_and_there_is_no_environment() throws Exception {
|
||||
this.reporter = new StreamSpanReporter(this.endpointLocator, this.spanMetricReporter, null);
|
||||
this.reporter = new StreamSpanReporter(this.endpointLocator, this.spanMetricReporter,
|
||||
null, new ArrayList<>());
|
||||
LinkedBlockingQueue<Span> queue = new LinkedBlockingQueue<>(1000);
|
||||
this.reporter.setQueue(queue);
|
||||
Span span = Span.builder().name("bar").exportable(true).build();
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.cloud.sleuth.zipkin.stream;
|
||||
|
||||
import java.util.Collections;
|
||||
import org.junit.Test;
|
||||
import org.springframework.cloud.sleuth.Span;
|
||||
import org.springframework.cloud.sleuth.stream.Host;
|
||||
@@ -26,8 +25,8 @@ import zipkin.Endpoint;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class ZipkinMessageListenerTests {
|
||||
Span span = new Span(1, 3, "http:name", 1L, Collections.<Long>emptyList(), 2L, true, true,
|
||||
"process");
|
||||
Span span = Span.builder().begin(1).end(3).name("http:name").traceId(1L).spanId(2L).remote(true)
|
||||
.exportable(true).processId("process").build();
|
||||
Host host = new Host("myservice", "1.2.3.4", 8080);
|
||||
Endpoint endpoint = Endpoint.builder()
|
||||
.serviceName("myservice")
|
||||
@@ -54,8 +53,8 @@ public class ZipkinMessageListenerTests {
|
||||
/** Sleuth timestamps are millisecond granularity while zipkin is microsecond. */
|
||||
@Test
|
||||
public void convertsTimestampAndDurationToMicroseconds() {
|
||||
Span span = new Span(1, 3, "http:name", 1L, Collections.<Long>emptyList(), 2L, false, true,
|
||||
"process");
|
||||
Span span = Span.builder().begin(1).end(3).name("http:name").traceId(1L).spanId(2L).remote(false)
|
||||
.exportable(true).processId("process").build();
|
||||
long start = System.currentTimeMillis();
|
||||
span.logEvent("hystrix/retry"); // System.currentTimeMillis
|
||||
|
||||
|
||||
@@ -43,11 +43,6 @@ public class DiscoveryClientEndpointLocator implements EndpointLocator {
|
||||
private final DiscoveryClient client;
|
||||
private final ZipkinProperties zipkinProperties;
|
||||
|
||||
@Deprecated
|
||||
public DiscoveryClientEndpointLocator(DiscoveryClient client) {
|
||||
this(client, new ZipkinProperties());
|
||||
}
|
||||
|
||||
public DiscoveryClientEndpointLocator(DiscoveryClient client,
|
||||
ZipkinProperties zipkinProperties) {
|
||||
this.client = client;
|
||||
|
||||
@@ -53,11 +53,6 @@ public class ServerPropertiesEndpointLocator implements EndpointLocator {
|
||||
private final ZipkinProperties zipkinProperties;
|
||||
private Integer port;
|
||||
|
||||
@Deprecated
|
||||
public ServerPropertiesEndpointLocator(ServerProperties serverProperties,String appName) {
|
||||
this(serverProperties,appName,new ZipkinProperties(), null);
|
||||
}
|
||||
|
||||
public ServerPropertiesEndpointLocator(ServerProperties serverProperties,
|
||||
String appName, ZipkinProperties zipkinProperties, InetUtils inetUtils) {
|
||||
this.serverProperties = serverProperties;
|
||||
|
||||
@@ -16,6 +16,13 @@
|
||||
|
||||
package org.springframework.cloud.sleuth.zipkin;
|
||||
|
||||
import org.springframework.cloud.commons.util.IdUtils;
|
||||
import org.springframework.cloud.sleuth.Log;
|
||||
import org.springframework.cloud.sleuth.Span;
|
||||
import org.springframework.cloud.sleuth.SpanAdjuster;
|
||||
import org.springframework.cloud.sleuth.SpanReporter;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.util.StringUtils;
|
||||
import zipkin.Annotation;
|
||||
import zipkin.BinaryAnnotation;
|
||||
import zipkin.Constants;
|
||||
@@ -23,19 +30,9 @@ import zipkin.Endpoint;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.cloud.commons.util.IdUtils;
|
||||
import org.springframework.cloud.sleuth.Log;
|
||||
import org.springframework.cloud.sleuth.NoOpSpanAdjuster;
|
||||
import org.springframework.cloud.sleuth.Span;
|
||||
import org.springframework.cloud.sleuth.SpanAdjuster;
|
||||
import org.springframework.cloud.sleuth.SpanReporter;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Listener of Sleuth events. Reports to Zipkin via {@link ZipkinSpanReporter}.
|
||||
*
|
||||
@@ -65,17 +62,6 @@ public class ZipkinSpanListener implements SpanReporter {
|
||||
// Visible for testing
|
||||
EndpointLocator endpointLocator;
|
||||
|
||||
@Deprecated
|
||||
public ZipkinSpanListener(ZipkinSpanReporter reporter, EndpointLocator endpointLocator) {
|
||||
this(reporter, endpointLocator, null);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public ZipkinSpanListener(ZipkinSpanReporter reporter, EndpointLocator endpointLocator,
|
||||
Environment environment) {
|
||||
this(reporter, endpointLocator, environment, Collections.<SpanAdjuster>singletonList(new NoOpSpanAdjuster()));
|
||||
}
|
||||
|
||||
public ZipkinSpanListener(ZipkinSpanReporter reporter, EndpointLocator endpointLocator,
|
||||
Environment environment, List<SpanAdjuster> spanAdjusters) {
|
||||
this.reporter = reporter;
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
package org.springframework.cloud.sleuth.zipkin;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.springframework.boot.autoconfigure.web.ServerProperties;
|
||||
@@ -18,11 +15,14 @@ import org.springframework.cloud.sleuth.sampler.AlwaysSampler;
|
||||
import org.springframework.cloud.sleuth.trace.DefaultTracer;
|
||||
import org.springframework.cloud.sleuth.util.ExceptionUtils;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import zipkin.Span;
|
||||
import zipkin.junit.HttpFailure;
|
||||
import zipkin.junit.ZipkinRule;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.BDDAssertions.then;
|
||||
@@ -131,7 +131,8 @@ public class HttpZipkinSpanReporterTest {
|
||||
Tracer tracer = new DefaultTracer(new AlwaysSampler(), new Random(), new DefaultSpanNamer(),
|
||||
new NoOpSpanLogger(), new ZipkinSpanListener(receivedSpan::set,
|
||||
new ServerPropertiesEndpointLocator(new ServerProperties(), "foo",
|
||||
new ZipkinProperties(), new InetUtils(new InetUtilsProperties()))), new TraceKeys());
|
||||
new ZipkinProperties(), new InetUtils(new InetUtilsProperties())),
|
||||
null, new ArrayList<>()), new TraceKeys());
|
||||
// tag::service_name[]
|
||||
org.springframework.cloud.sleuth.Span newSpan = tracer.createSpan("redis");
|
||||
try {
|
||||
|
||||
@@ -284,7 +284,7 @@ public class ZipkinSpanListenerTests {
|
||||
public void shouldNotAddAnyServiceIdTagWhenSpanContainsRpcEventAndThereIsNoEnvironment() {
|
||||
this.parent.logEvent(Span.CLIENT_RECV);
|
||||
ZipkinSpanListener spanListener = new ZipkinSpanListener(this.spanReporter,
|
||||
this.endpointLocator, null);
|
||||
this.endpointLocator, null, new ArrayList<>());
|
||||
|
||||
zipkin.Span result = spanListener.convert(this.parent);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user