Updates to latest Brave, removing deprecated usage
Notably, this avoids `Span.remoteEndpoint` and deprecated test helpers.
This commit is contained in:
@@ -75,35 +75,47 @@ Spans have a context that includes trace identifiers that place the span at the
|
||||
|
||||
==== Local Tracing
|
||||
|
||||
When tracing local code, you can run it inside a span, as shown in the following example:
|
||||
|
||||
```java
|
||||
|
||||
@Autowired Tracer tracer;
|
||||
|
||||
Span span = tracer.newTrace().name("encode").start();
|
||||
try {
|
||||
doSomethingExpensive();
|
||||
} finally {
|
||||
span.finish();
|
||||
}
|
||||
```
|
||||
|
||||
In the preceding example, the span is the root of the trace.
|
||||
In many cases, the span is part of an existing trace.
|
||||
When this is the case, call `newChild` instead of `newTrace`, as shown in the following example:
|
||||
When tracing code that never leaves your process, run it inside a scoped span.
|
||||
|
||||
```java
|
||||
@Autowired Tracer tracer;
|
||||
|
||||
Span span = tracer.newChild(root.context()).name("encode").start();
|
||||
// Start a new trace or a span within an existing trace representing an operation
|
||||
ScopedSpan span = tracer.startScopedSpan("encode");
|
||||
try {
|
||||
doSomethingExpensive();
|
||||
// The span is in "scope" meaning downstream code such as loggers can see trace IDs
|
||||
return encoder.encode();
|
||||
} catch (RuntimeException | Error e) {
|
||||
span.error(e); // Unless you handle exceptions, you might not know the operation failed!
|
||||
throw e;
|
||||
} finally {
|
||||
span.finish();
|
||||
span.finish(); // always finish the span
|
||||
}
|
||||
```
|
||||
|
||||
When you need more features, or finer control, use the `Span` type:
|
||||
```java
|
||||
@Autowired Tracer tracer;
|
||||
|
||||
// Start a new trace or a span within an existing trace representing an operation
|
||||
Span span = tracer.nextSpan().name("encode").start();
|
||||
// Put the span in "scope" so that downstream code such as loggers can see trace IDs
|
||||
try (SpanInScope ws = tracer.withSpanInScope(span)) {
|
||||
return encoder.encode();
|
||||
} catch (RuntimeException | Error e) {
|
||||
span.error(e); // Unless you handle exceptions, you might not know the operation failed!
|
||||
throw e;
|
||||
} finally {
|
||||
span.finish(); // note the scope is independent of the span. Always finish a span.
|
||||
}
|
||||
```
|
||||
|
||||
Both of the above examples report the exact same span on finish!
|
||||
|
||||
In the above example, the span will be either a new root span or the
|
||||
next child in an existing trace.
|
||||
|
||||
|
||||
==== Customizing Spans
|
||||
|
||||
Once you have a span, you can add tags to it.
|
||||
@@ -156,23 +168,26 @@ RPC tracing is often done automatically by interceptors. Behind the scenes, they
|
||||
The following example shows how to add a client span:
|
||||
|
||||
```java
|
||||
@Autowired Tracing tracing;
|
||||
@Autowired Tracer tracer;
|
||||
|
||||
// before you send a request, add metadata that describes the operation
|
||||
span = tracer.newTrace().name("get").type(CLIENT);
|
||||
span.tag("clnt/finagle.version", "6.36.0");
|
||||
span.tag(TraceKeys.HTTP_PATH, "/api");
|
||||
span.remoteEndpoint(Endpoint.builder()
|
||||
.serviceName("backend")
|
||||
.ipv4(127 << 24 | 1)
|
||||
.port(8080).build());
|
||||
span = tracer.nextSpan().name(service + "/" + method).kind(CLIENT);
|
||||
span.tag("myrpc.version", "1.0.0");
|
||||
span.remoteServiceName("backend");
|
||||
span.remoteIpAndPort("172.3.4.1", 8108);
|
||||
|
||||
// Add the trace context to the request, so it can be propagated in-band
|
||||
tracing.propagation().injector(Request::addHeader)
|
||||
.inject(span.context(), request);
|
||||
|
||||
// when the request is scheduled, start the span
|
||||
span.start();
|
||||
|
||||
// if you have callbacks for when data is on the wire, note those events
|
||||
span.annotate(Constants.WIRE_SEND);
|
||||
span.annotate(Constants.WIRE_RECV);
|
||||
// if there is an error, tag the span
|
||||
span.tag("error", error.getCode());
|
||||
// or if there is an exception
|
||||
span.error(exception);
|
||||
|
||||
// when the response is complete, finish the span
|
||||
span.finish();
|
||||
@@ -187,10 +202,11 @@ to indicate that the response was received. In one-way tracing, you use
|
||||
|
||||
The following example shows how a client might model a one-way operation:
|
||||
```java
|
||||
@Autowired Tracing tracing;
|
||||
@Autowired Tracer tracer;
|
||||
|
||||
// start a new span representing a client request
|
||||
oneWaySend = tracer.newSpan(parent).kind(Span.Kind.CLIENT);
|
||||
oneWaySend = tracer.nextSpan().name(service + "/" + method).kind(CLIENT);
|
||||
|
||||
// Add the trace context to the request, so it can be propagated in-band
|
||||
tracing.propagation().injector(Request::addHeader)
|
||||
@@ -243,16 +259,24 @@ Most users use a framework interceptor to automate this sort of policy.
|
||||
The following example shows how that might work internally:
|
||||
|
||||
```java
|
||||
@Autowired Tracing tracing;
|
||||
@Autowired Tracer tracer;
|
||||
|
||||
// derives a sample rate from an annotation on a java method
|
||||
DeclarativeSampler<Traced> sampler = DeclarativeSampler.create(Traced::sampleRate);
|
||||
|
||||
@Around("@annotation(traced)")
|
||||
public Object traceThing(ProceedingJoinPoint pjp, Traced traced) throws Throwable {
|
||||
Span span = tracing.tracer().newTrace(sampler.sample(traced))...
|
||||
// When there is no trace in progress, this decides using an annotation
|
||||
Sampler decideUsingAnnotation = declarativeSampler.toSampler(traced);
|
||||
Tracer tracer = tracer.withSampler(decideUsingAnnotation);
|
||||
|
||||
// This code looks the same as if there was no declarative override
|
||||
ScopedSpan span = tracer.startScopedSpan(spanName(pjp));
|
||||
try {
|
||||
return pjp.proceed();
|
||||
} catch (RuntimeException | Error e) {
|
||||
span.error(e);
|
||||
throw e;
|
||||
} finally {
|
||||
span.finish();
|
||||
}
|
||||
@@ -269,15 +293,20 @@ The following example shows how that might work internally:
|
||||
|
||||
```java
|
||||
@Autowired Tracer tracer;
|
||||
@Autowired Sampler fallback;
|
||||
|
||||
Span newTrace(Request input) {
|
||||
SamplingFlags flags = SamplingFlags.NONE;
|
||||
if (input.url().startsWith("/experimental")) {
|
||||
flags = SamplingFlags.SAMPLED;
|
||||
} else if (input.url().startsWith("/static")) {
|
||||
flags = SamplingFlags.NOT_SAMPLED;
|
||||
}
|
||||
return tracer.newTrace(flags);
|
||||
Span nextSpan(final Request input) {
|
||||
Sampler requestBased = Sampler() {
|
||||
@Override public boolean isSampled(long traceId) {
|
||||
if (input.url().startsWith("/experimental")) {
|
||||
return true;
|
||||
} else if (input.url().startsWith("/static")) {
|
||||
return false;
|
||||
}
|
||||
return fallback.isSampled(traceId);
|
||||
}
|
||||
};
|
||||
return tracer.withSampler(requestBased).nextSpan();
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
2
pom.xml
2
pom.xml
@@ -273,7 +273,7 @@
|
||||
<spring-cloud-stream.version>Fishtown.BUILD-SNAPSHOT</spring-cloud-stream.version>
|
||||
<spring-cloud-netflix.version>2.1.0.BUILD-SNAPSHOT</spring-cloud-netflix.version>
|
||||
<spring-cloud-openfeign.version>2.1.0.BUILD-SNAPSHOT</spring-cloud-openfeign.version>
|
||||
<brave.version>5.3.0</brave.version>
|
||||
<brave.version>5.3.3</brave.version>
|
||||
<spring-security-boot-autoconfigure.version>2.0.4.RELEASE</spring-security-boot-autoconfigure.version>
|
||||
</properties>
|
||||
|
||||
|
||||
@@ -43,7 +43,6 @@ import org.springframework.messaging.support.ExecutorChannelInterceptor;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
import org.springframework.messaging.support.MessageHeaderAccessor;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import zipkin2.Endpoint;
|
||||
|
||||
/**
|
||||
* This starts and propagates {@link Span.Kind#PRODUCER} span for each message sent (via native
|
||||
@@ -145,7 +144,7 @@ public final class TracingChannelInterceptor extends ChannelInterceptorAdapter
|
||||
this.injector.inject(span.context(), headers);
|
||||
if (!span.isNoop()) {
|
||||
span.kind(Span.Kind.PRODUCER).name("send").start();
|
||||
span.remoteEndpoint(Endpoint.newBuilder().serviceName(REMOTE_SERVICE_NAME).build());
|
||||
span.remoteServiceName(REMOTE_SERVICE_NAME);
|
||||
addTags(message, span, channel);
|
||||
}
|
||||
if (log.isDebugEnabled()) {
|
||||
@@ -211,7 +210,7 @@ public final class TracingChannelInterceptor extends ChannelInterceptorAdapter
|
||||
this.injector.inject(span.context(), headers);
|
||||
if (!span.isNoop()) {
|
||||
span.kind(Span.Kind.CONSUMER).name("receive").start();
|
||||
span.remoteEndpoint(Endpoint.newBuilder().serviceName(REMOTE_SERVICE_NAME).build());
|
||||
span.remoteServiceName(REMOTE_SERVICE_NAME);
|
||||
addTags(message, span, channel);
|
||||
}
|
||||
if (log.isDebugEnabled()) {
|
||||
@@ -248,7 +247,7 @@ public final class TracingChannelInterceptor extends ChannelInterceptorAdapter
|
||||
Span consumerSpan = this.tracer.nextSpan(extracted);
|
||||
if (!consumerSpan.isNoop()) {
|
||||
consumerSpan.kind(Span.Kind.CONSUMER).start();
|
||||
consumerSpan.remoteEndpoint(Endpoint.newBuilder().serviceName(REMOTE_SERVICE_NAME).build());
|
||||
consumerSpan.remoteServiceName(REMOTE_SERVICE_NAME);
|
||||
addTags(message, consumerSpan, channel);
|
||||
consumerSpan.finish();
|
||||
}
|
||||
|
||||
@@ -27,7 +27,8 @@ import java.util.concurrent.Future;
|
||||
import brave.Span;
|
||||
import brave.Tracer;
|
||||
import brave.Tracing;
|
||||
import brave.propagation.StrictCurrentTraceContext;
|
||||
import brave.propagation.StrictScopeDecorator;
|
||||
import brave.propagation.ThreadLocalCurrentTraceContext;
|
||||
import brave.sampler.Sampler;
|
||||
import org.assertj.core.api.BDDAssertions;
|
||||
import org.junit.Before;
|
||||
@@ -53,7 +54,9 @@ public class SpringCloudSleuthDocTests {
|
||||
|
||||
ArrayListSpanReporter reporter = new ArrayListSpanReporter();
|
||||
Tracing tracing = Tracing.newBuilder()
|
||||
.currentTraceContext(new StrictCurrentTraceContext())
|
||||
.currentTraceContext(ThreadLocalCurrentTraceContext.newBuilder()
|
||||
.addScopeDecorator(StrictScopeDecorator.create())
|
||||
.build())
|
||||
.sampler(Sampler.ALWAYS_SAMPLE)
|
||||
.spanReporter(this.reporter)
|
||||
.build();
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
package org.springframework.cloud.sleuth.instrument.async;
|
||||
|
||||
import brave.Tracing;
|
||||
import brave.propagation.StrictCurrentTraceContext;
|
||||
import brave.propagation.StrictScopeDecorator;
|
||||
import brave.propagation.ThreadLocalCurrentTraceContext;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.reflect.MethodSignature;
|
||||
import org.assertj.core.api.BDDAssertions;
|
||||
@@ -19,7 +20,9 @@ public class TraceAsyncAspectTest {
|
||||
|
||||
ArrayListSpanReporter reporter = new ArrayListSpanReporter();
|
||||
Tracing tracing = Tracing.newBuilder()
|
||||
.currentTraceContext(new StrictCurrentTraceContext())
|
||||
.currentTraceContext(ThreadLocalCurrentTraceContext.newBuilder()
|
||||
.addScopeDecorator(StrictScopeDecorator.create())
|
||||
.build())
|
||||
.spanReporter(this.reporter)
|
||||
.build();
|
||||
ProceedingJoinPoint point = Mockito.mock(ProceedingJoinPoint.class);
|
||||
|
||||
@@ -23,7 +23,8 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import brave.Span;
|
||||
import brave.Tracer;
|
||||
import brave.Tracing;
|
||||
import brave.propagation.StrictCurrentTraceContext;
|
||||
import brave.propagation.StrictScopeDecorator;
|
||||
import brave.propagation.ThreadLocalCurrentTraceContext;
|
||||
import org.assertj.core.api.BDDAssertions;
|
||||
import org.awaitility.Awaitility;
|
||||
import org.junit.Test;
|
||||
@@ -37,7 +38,9 @@ public class TraceAsyncListenableTaskExecutorTest {
|
||||
|
||||
AsyncListenableTaskExecutor delegate = new SimpleAsyncTaskExecutor();
|
||||
Tracing tracing = Tracing.newBuilder()
|
||||
.currentTraceContext(new StrictCurrentTraceContext())
|
||||
.currentTraceContext(ThreadLocalCurrentTraceContext.newBuilder()
|
||||
.addScopeDecorator(StrictScopeDecorator.create())
|
||||
.build())
|
||||
.build();
|
||||
Tracer tracer = this.tracing.tracer();
|
||||
TraceAsyncListenableTaskExecutor traceAsyncListenableTaskExecutor = new TraceAsyncListenableTaskExecutor(
|
||||
|
||||
@@ -23,7 +23,8 @@ import java.util.concurrent.Executors;
|
||||
import brave.Span;
|
||||
import brave.Tracer;
|
||||
import brave.Tracing;
|
||||
import brave.propagation.StrictCurrentTraceContext;
|
||||
import brave.propagation.StrictScopeDecorator;
|
||||
import brave.propagation.ThreadLocalCurrentTraceContext;
|
||||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -40,7 +41,9 @@ public class TraceCallableTests {
|
||||
ExecutorService executor = Executors.newSingleThreadExecutor();
|
||||
ArrayListSpanReporter reporter = new ArrayListSpanReporter();
|
||||
Tracing tracing = Tracing.newBuilder()
|
||||
.currentTraceContext(new StrictCurrentTraceContext())
|
||||
.currentTraceContext(ThreadLocalCurrentTraceContext.newBuilder()
|
||||
.addScopeDecorator(StrictScopeDecorator.create())
|
||||
.build())
|
||||
.spanReporter(this.reporter)
|
||||
.build();
|
||||
Tracer tracer = this.tracing.tracer();
|
||||
|
||||
@@ -23,7 +23,8 @@ import java.util.concurrent.atomic.AtomicReference;
|
||||
import brave.Span;
|
||||
import brave.Tracer;
|
||||
import brave.Tracing;
|
||||
import brave.propagation.StrictCurrentTraceContext;
|
||||
import brave.propagation.StrictScopeDecorator;
|
||||
import brave.propagation.ThreadLocalCurrentTraceContext;
|
||||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -40,7 +41,9 @@ public class TraceRunnableTests {
|
||||
ExecutorService executor = Executors.newSingleThreadExecutor();
|
||||
ArrayListSpanReporter reporter = new ArrayListSpanReporter();
|
||||
Tracing tracing = Tracing.newBuilder()
|
||||
.currentTraceContext(new StrictCurrentTraceContext())
|
||||
.currentTraceContext(ThreadLocalCurrentTraceContext.newBuilder()
|
||||
.addScopeDecorator(StrictScopeDecorator.create())
|
||||
.build())
|
||||
.spanReporter(this.reporter)
|
||||
.build();
|
||||
Tracer tracer = this.tracing.tracer();
|
||||
|
||||
@@ -32,7 +32,8 @@ import brave.ScopedSpan;
|
||||
import brave.Span;
|
||||
import brave.Tracer;
|
||||
import brave.Tracing;
|
||||
import brave.propagation.StrictCurrentTraceContext;
|
||||
import brave.propagation.StrictScopeDecorator;
|
||||
import brave.propagation.ThreadLocalCurrentTraceContext;
|
||||
import org.assertj.core.api.BDDAssertions;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
@@ -60,7 +61,9 @@ public class TraceableExecutorServiceTests {
|
||||
ExecutorService traceManagerableExecutorService;
|
||||
ArrayListSpanReporter reporter = new ArrayListSpanReporter();
|
||||
Tracing tracing = Tracing.newBuilder()
|
||||
.currentTraceContext(new StrictCurrentTraceContext())
|
||||
.currentTraceContext(ThreadLocalCurrentTraceContext.newBuilder()
|
||||
.addScopeDecorator(StrictScopeDecorator.create())
|
||||
.build())
|
||||
.spanReporter(this.reporter)
|
||||
.build();
|
||||
Tracer tracer = this.tracing.tracer();
|
||||
|
||||
@@ -22,7 +22,8 @@ import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import brave.Tracing;
|
||||
import brave.propagation.StrictCurrentTraceContext;
|
||||
import brave.propagation.StrictScopeDecorator;
|
||||
import brave.propagation.ThreadLocalCurrentTraceContext;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -46,7 +47,9 @@ import static org.mockito.BDDMockito.then;
|
||||
public class TraceableScheduledExecutorServiceTest {
|
||||
|
||||
Tracing tracing = Tracing.newBuilder()
|
||||
.currentTraceContext(new StrictCurrentTraceContext())
|
||||
.currentTraceContext(ThreadLocalCurrentTraceContext.newBuilder()
|
||||
.addScopeDecorator(StrictScopeDecorator.create())
|
||||
.build())
|
||||
.build();
|
||||
@Mock
|
||||
BeanFactory beanFactory;
|
||||
|
||||
@@ -21,7 +21,8 @@ import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import brave.Tracing;
|
||||
import brave.propagation.StrictCurrentTraceContext;
|
||||
import brave.propagation.StrictScopeDecorator;
|
||||
import brave.propagation.ThreadLocalCurrentTraceContext;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -51,7 +52,9 @@ public class SleuthHystrixConcurrencyStrategyTest {
|
||||
|
||||
ArrayListSpanReporter reporter = new ArrayListSpanReporter();
|
||||
Tracing tracing = Tracing.newBuilder()
|
||||
.currentTraceContext(new StrictCurrentTraceContext())
|
||||
.currentTraceContext(ThreadLocalCurrentTraceContext.newBuilder()
|
||||
.addScopeDecorator(StrictScopeDecorator.create())
|
||||
.build())
|
||||
.spanReporter(this.reporter)
|
||||
.build();
|
||||
|
||||
|
||||
@@ -22,8 +22,9 @@ import java.util.concurrent.atomic.AtomicReference;
|
||||
import brave.Span;
|
||||
import brave.Tracer;
|
||||
import brave.Tracing;
|
||||
import brave.propagation.StrictCurrentTraceContext;
|
||||
import brave.sampler.Sampler;
|
||||
import brave.propagation.StrictScopeDecorator;
|
||||
import brave.propagation.ThreadLocalCurrentTraceContext;
|
||||
import com.netflix.hystrix.HystrixCommand;
|
||||
import com.netflix.hystrix.HystrixCommandKey;
|
||||
import com.netflix.hystrix.HystrixCommandProperties;
|
||||
@@ -42,7 +43,9 @@ public class TraceCommandTests {
|
||||
|
||||
ArrayListSpanReporter reporter = new ArrayListSpanReporter();
|
||||
Tracing tracing = Tracing.newBuilder()
|
||||
.currentTraceContext(new StrictCurrentTraceContext())
|
||||
.currentTraceContext(ThreadLocalCurrentTraceContext.newBuilder()
|
||||
.addScopeDecorator(StrictScopeDecorator.create())
|
||||
.build())
|
||||
.spanReporter(this.reporter)
|
||||
.sampler(Sampler.ALWAYS_SAMPLE)
|
||||
.build();
|
||||
|
||||
@@ -25,7 +25,8 @@ import javax.annotation.PreDestroy;
|
||||
import brave.Span;
|
||||
import brave.Tracer;
|
||||
import brave.Tracing;
|
||||
import brave.propagation.StrictCurrentTraceContext;
|
||||
import brave.propagation.StrictScopeDecorator;
|
||||
import brave.propagation.ThreadLocalCurrentTraceContext;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -135,7 +136,9 @@ public class ITTracingChannelInterceptor implements MessageHandler {
|
||||
|
||||
@Bean Tracing tracing() {
|
||||
return Tracing.newBuilder()
|
||||
.currentTraceContext(new StrictCurrentTraceContext())
|
||||
.currentTraceContext(ThreadLocalCurrentTraceContext.newBuilder()
|
||||
.addScopeDecorator(StrictScopeDecorator.create())
|
||||
.build())
|
||||
.spanReporter(spans()::add).build();
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,8 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import brave.Tracing;
|
||||
import brave.propagation.StrictCurrentTraceContext;
|
||||
import brave.propagation.StrictScopeDecorator;
|
||||
import brave.propagation.ThreadLocalCurrentTraceContext;
|
||||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
import org.springframework.integration.channel.DirectChannel;
|
||||
@@ -49,7 +50,10 @@ public class TracingChannelInterceptorTest {
|
||||
|
||||
List<Span> spans = new ArrayList<>();
|
||||
ChannelInterceptor interceptor = TracingChannelInterceptor.create(Tracing.newBuilder()
|
||||
.currentTraceContext(new StrictCurrentTraceContext()).spanReporter(spans::add)
|
||||
.currentTraceContext(ThreadLocalCurrentTraceContext.newBuilder()
|
||||
.addScopeDecorator(StrictScopeDecorator.create())
|
||||
.build())
|
||||
.spanReporter(spans::add)
|
||||
.build());
|
||||
|
||||
QueueChannel channel = new QueueChannel();
|
||||
|
||||
@@ -24,8 +24,6 @@ import brave.Tracing;
|
||||
import brave.opentracing.BraveSpan;
|
||||
import brave.opentracing.BraveSpanContext;
|
||||
import brave.opentracing.BraveTracer;
|
||||
import brave.propagation.CurrentTraceContext;
|
||||
import brave.propagation.StrictCurrentTraceContext;
|
||||
import brave.propagation.TraceContext;
|
||||
import brave.sampler.Sampler;
|
||||
import io.opentracing.Scope;
|
||||
|
||||
@@ -28,7 +28,8 @@ import java.util.concurrent.ThreadFactory;
|
||||
|
||||
import brave.Tracer;
|
||||
import brave.Tracing;
|
||||
import brave.propagation.StrictCurrentTraceContext;
|
||||
import brave.propagation.StrictScopeDecorator;
|
||||
import brave.propagation.ThreadLocalCurrentTraceContext;
|
||||
import rx.functions.Action0;
|
||||
import rx.plugins.RxJavaErrorHandler;
|
||||
import rx.plugins.RxJavaObservableExecutionHook;
|
||||
@@ -50,7 +51,9 @@ public class SleuthRxJavaSchedulersHookTests {
|
||||
List<String> threadsToIgnore = new ArrayList<>();
|
||||
ArrayListSpanReporter reporter = new ArrayListSpanReporter();
|
||||
Tracing tracing = Tracing.newBuilder()
|
||||
.currentTraceContext(new StrictCurrentTraceContext())
|
||||
.currentTraceContext(ThreadLocalCurrentTraceContext.newBuilder()
|
||||
.addScopeDecorator(StrictScopeDecorator.create())
|
||||
.build())
|
||||
.spanReporter(this.reporter)
|
||||
.build();
|
||||
Tracer tracer = this.tracing.tracer();
|
||||
|
||||
@@ -25,7 +25,8 @@ import brave.Span;
|
||||
import brave.Tracer;
|
||||
import brave.Tracing;
|
||||
import brave.http.HttpTracing;
|
||||
import brave.propagation.StrictCurrentTraceContext;
|
||||
import brave.propagation.StrictScopeDecorator;
|
||||
import brave.propagation.ThreadLocalCurrentTraceContext;
|
||||
import brave.sampler.Sampler;
|
||||
import brave.servlet.TracingFilter;
|
||||
import org.junit.After;
|
||||
@@ -60,7 +61,9 @@ public class TraceFilterTests {
|
||||
|
||||
ArrayListSpanReporter reporter = new ArrayListSpanReporter();
|
||||
Tracing tracing = Tracing.newBuilder()
|
||||
.currentTraceContext(new StrictCurrentTraceContext())
|
||||
.currentTraceContext(ThreadLocalCurrentTraceContext.newBuilder()
|
||||
.addScopeDecorator(StrictScopeDecorator.create())
|
||||
.build())
|
||||
.spanReporter(this.reporter)
|
||||
.build();
|
||||
Tracer tracer = this.tracing.tracer();
|
||||
@@ -108,7 +111,9 @@ public class TraceFilterTests {
|
||||
|
||||
private Filter neverSampleFilter() {
|
||||
Tracing tracing = Tracing.newBuilder()
|
||||
.currentTraceContext(new StrictCurrentTraceContext())
|
||||
.currentTraceContext(ThreadLocalCurrentTraceContext.newBuilder()
|
||||
.addScopeDecorator(StrictScopeDecorator.create())
|
||||
.build())
|
||||
.spanReporter(this.reporter)
|
||||
.sampler(Sampler.NEVER_SAMPLE)
|
||||
.supportsJoin(false)
|
||||
@@ -235,7 +240,9 @@ public class TraceFilterTests {
|
||||
@Test
|
||||
public void createsChildFromHeadersWhenJoinUnsupported() throws Exception {
|
||||
Tracing tracing = Tracing.newBuilder()
|
||||
.currentTraceContext(new StrictCurrentTraceContext())
|
||||
.currentTraceContext(ThreadLocalCurrentTraceContext.newBuilder()
|
||||
.addScopeDecorator(StrictScopeDecorator.create())
|
||||
.build())
|
||||
.spanReporter(this.reporter)
|
||||
.supportsJoin(false)
|
||||
.build();
|
||||
|
||||
@@ -25,8 +25,9 @@ import brave.Span;
|
||||
import brave.Tracer;
|
||||
import brave.Tracing;
|
||||
import brave.http.HttpTracing;
|
||||
import brave.propagation.StrictCurrentTraceContext;
|
||||
import brave.sampler.Sampler;
|
||||
import brave.propagation.StrictScopeDecorator;
|
||||
import brave.propagation.ThreadLocalCurrentTraceContext;
|
||||
import brave.spring.web.TracingClientHttpRequestInterceptor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.junit.After;
|
||||
@@ -60,7 +61,9 @@ public class TraceRestTemplateInterceptorTests {
|
||||
new MockMvcClientHttpRequestFactory(this.mockMvc));
|
||||
ArrayListSpanReporter reporter = new ArrayListSpanReporter();
|
||||
Tracing tracing = Tracing.newBuilder()
|
||||
.currentTraceContext(new StrictCurrentTraceContext())
|
||||
.currentTraceContext(ThreadLocalCurrentTraceContext.newBuilder()
|
||||
.addScopeDecorator(StrictScopeDecorator.create())
|
||||
.build())
|
||||
.spanReporter(this.reporter)
|
||||
.build();
|
||||
Tracer tracer = this.tracing.tracer();
|
||||
@@ -136,7 +139,9 @@ public class TraceRestTemplateInterceptorTests {
|
||||
@Test
|
||||
public void notSampledHeaderAddedWhenNotExportable() {
|
||||
Tracing tracing = Tracing.newBuilder()
|
||||
.currentTraceContext(new StrictCurrentTraceContext())
|
||||
.currentTraceContext(ThreadLocalCurrentTraceContext.newBuilder()
|
||||
.addScopeDecorator(StrictScopeDecorator.create())
|
||||
.build())
|
||||
.spanReporter(this.reporter)
|
||||
.sampler(Sampler.NEVER_SAMPLE)
|
||||
.build();
|
||||
|
||||
@@ -36,7 +36,8 @@ import brave.Span;
|
||||
import brave.Tracer;
|
||||
import brave.Tracing;
|
||||
import brave.http.HttpTracing;
|
||||
import brave.propagation.StrictCurrentTraceContext;
|
||||
import brave.propagation.StrictScopeDecorator;
|
||||
import brave.propagation.ThreadLocalCurrentTraceContext;
|
||||
import brave.spring.web.TracingClientHttpRequestInterceptor;
|
||||
import okhttp3.mockwebserver.MockResponse;
|
||||
import okhttp3.mockwebserver.MockWebServer;
|
||||
@@ -53,7 +54,9 @@ public class TraceRestTemplateInterceptorIntegrationTests {
|
||||
|
||||
ArrayListSpanReporter reporter = new ArrayListSpanReporter();
|
||||
Tracing tracing = Tracing.newBuilder()
|
||||
.currentTraceContext(new StrictCurrentTraceContext())
|
||||
.currentTraceContext(ThreadLocalCurrentTraceContext.newBuilder()
|
||||
.addScopeDecorator(StrictScopeDecorator.create())
|
||||
.build())
|
||||
.spanReporter(this.reporter)
|
||||
.build();
|
||||
Tracer tracer = this.tracing.tracer();
|
||||
|
||||
@@ -23,7 +23,8 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import brave.Tracing;
|
||||
import brave.http.HttpTracing;
|
||||
import brave.propagation.StrictCurrentTraceContext;
|
||||
import brave.propagation.StrictScopeDecorator;
|
||||
import brave.propagation.ThreadLocalCurrentTraceContext;
|
||||
import feign.Client;
|
||||
import feign.Feign;
|
||||
import feign.FeignException;
|
||||
@@ -60,7 +61,9 @@ public class FeignRetriesTests {
|
||||
|
||||
ArrayListSpanReporter reporter = new ArrayListSpanReporter();
|
||||
Tracing tracing = Tracing.newBuilder()
|
||||
.currentTraceContext(new StrictCurrentTraceContext())
|
||||
.currentTraceContext(ThreadLocalCurrentTraceContext.newBuilder()
|
||||
.addScopeDecorator(StrictScopeDecorator.create())
|
||||
.build())
|
||||
.spanReporter(this.reporter)
|
||||
.build();
|
||||
HttpTracing httpTracing = HttpTracing.newBuilder(this.tracing)
|
||||
|
||||
@@ -20,7 +20,8 @@ import java.io.IOException;
|
||||
|
||||
import brave.Tracing;
|
||||
import brave.http.HttpTracing;
|
||||
import brave.propagation.StrictCurrentTraceContext;
|
||||
import brave.propagation.StrictScopeDecorator;
|
||||
import brave.propagation.ThreadLocalCurrentTraceContext;
|
||||
import feign.Client;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.junit.Before;
|
||||
@@ -46,7 +47,9 @@ public class TraceFeignAspectTests {
|
||||
@Mock ProceedingJoinPoint pjp;
|
||||
@Mock TraceLoadBalancerFeignClient traceLoadBalancerFeignClient;
|
||||
Tracing tracing = Tracing.newBuilder()
|
||||
.currentTraceContext(new StrictCurrentTraceContext())
|
||||
.currentTraceContext(ThreadLocalCurrentTraceContext.newBuilder()
|
||||
.addScopeDecorator(StrictScopeDecorator.create())
|
||||
.build())
|
||||
.build();
|
||||
HttpTracing httpTracing = HttpTracing.newBuilder(this.tracing)
|
||||
.clientParser(SleuthHttpParserAccessor.getClient())
|
||||
|
||||
@@ -24,7 +24,8 @@ import brave.Span;
|
||||
import brave.Tracer;
|
||||
import brave.Tracing;
|
||||
import brave.http.HttpTracing;
|
||||
import brave.propagation.StrictCurrentTraceContext;
|
||||
import brave.propagation.StrictScopeDecorator;
|
||||
import brave.propagation.ThreadLocalCurrentTraceContext;
|
||||
import feign.Client;
|
||||
import feign.Request;
|
||||
import org.assertj.core.api.BDDAssertions;
|
||||
@@ -49,7 +50,9 @@ public class TracingFeignClientTests {
|
||||
ArrayListSpanReporter reporter = new ArrayListSpanReporter();
|
||||
@Mock BeanFactory beanFactory;
|
||||
Tracing tracing = Tracing.newBuilder()
|
||||
.currentTraceContext(new StrictCurrentTraceContext())
|
||||
.currentTraceContext(ThreadLocalCurrentTraceContext.newBuilder()
|
||||
.addScopeDecorator(StrictScopeDecorator.create())
|
||||
.build())
|
||||
.spanReporter(this.reporter)
|
||||
.build();
|
||||
Tracer tracer = this.tracing.tracer();
|
||||
|
||||
@@ -25,7 +25,8 @@ import brave.Span;
|
||||
import brave.Tracer;
|
||||
import brave.Tracing;
|
||||
import brave.http.HttpTracing;
|
||||
import brave.propagation.StrictCurrentTraceContext;
|
||||
import brave.propagation.StrictScopeDecorator;
|
||||
import brave.propagation.ThreadLocalCurrentTraceContext;
|
||||
import com.netflix.zuul.context.RequestContext;
|
||||
import com.netflix.zuul.monitoring.TracerFactory;
|
||||
import org.junit.After;
|
||||
@@ -53,7 +54,9 @@ public class TracePostZuulFilterTests {
|
||||
|
||||
ArrayListSpanReporter reporter = new ArrayListSpanReporter();
|
||||
Tracing tracing = Tracing.newBuilder()
|
||||
.currentTraceContext(new StrictCurrentTraceContext())
|
||||
.currentTraceContext(ThreadLocalCurrentTraceContext.newBuilder()
|
||||
.addScopeDecorator(StrictScopeDecorator.create())
|
||||
.build())
|
||||
.spanReporter(this.reporter)
|
||||
.build();
|
||||
HttpTracing httpTracing = HttpTracing.newBuilder(this.tracing)
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
<name>spring-cloud-sleuth-dependencies</name>
|
||||
<description>Spring Cloud Sleuth Dependencies</description>
|
||||
<properties>
|
||||
<brave.opentracing.version>0.32.1</brave.opentracing.version>
|
||||
<brave.opentracing.version>0.33.0</brave.opentracing.version>
|
||||
</properties>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
|
||||
Reference in New Issue
Block a user