Removed the last remnants of the legacy Spans... goodbye
This commit is contained in:
@@ -23,6 +23,9 @@ import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Future;
|
||||
import javax.annotation.PreDestroy;
|
||||
|
||||
import brave.Span;
|
||||
import brave.Tracer;
|
||||
import brave.sampler.Sampler;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -32,13 +35,9 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
|
||||
import org.springframework.boot.web.servlet.context.ServletWebServerInitializedEvent;
|
||||
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
|
||||
import org.springframework.cloud.sleuth.Sampler;
|
||||
import org.springframework.cloud.sleuth.Span;
|
||||
import org.springframework.cloud.sleuth.Tracer;
|
||||
import org.springframework.cloud.sleuth.annotation.ContinueSpan;
|
||||
import org.springframework.cloud.sleuth.annotation.NewSpan;
|
||||
import org.springframework.cloud.sleuth.annotation.SpanTag;
|
||||
import org.springframework.cloud.sleuth.sampler.AlwaysSampler;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
@@ -110,7 +109,7 @@ public class SleuthBenchmarkingSpringApp implements
|
||||
}
|
||||
|
||||
@Bean Sampler alwaysSampler() {
|
||||
return new AlwaysSampler();
|
||||
return Sampler.ALWAYS_SAMPLE;
|
||||
}
|
||||
|
||||
@Bean AnotherClass anotherClass() {
|
||||
@@ -139,11 +138,11 @@ class AClass {
|
||||
}
|
||||
|
||||
public String manualSpan() {
|
||||
Span manual = this.tracer.createSpan("span-name");
|
||||
try {
|
||||
Span manual = this.tracer.nextSpan().name("span-name");
|
||||
try (Tracer.SpanInScope ws = this.tracer.withSpanInScope(manual)) {
|
||||
return this.anotherClass.continuedSpan();
|
||||
} finally {
|
||||
this.tracer.close(manual);
|
||||
manual.finish();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,11 +165,11 @@ class AnotherClass {
|
||||
}
|
||||
|
||||
public String continuedSpan() {
|
||||
Span continuedSpan = this.tracer.continueSpan(this.tracer.getCurrentSpan());
|
||||
this.tracer.addTag("foo", "bar");
|
||||
continuedSpan.logEvent("continuedspan.before");
|
||||
Span span = this.tracer.currentSpan();
|
||||
span.tag("foo", "bar");
|
||||
span.annotate("continuedspan.before");
|
||||
String response = "continued";
|
||||
continuedSpan.logEvent("continuedspan.after");
|
||||
span.annotate("continuedspan.after");
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,6 @@ import org.openjdk.jmh.annotations.Threads;
|
||||
import org.openjdk.jmh.annotations.Warmup;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.cloud.sleuth.benchmarks.app.SleuthBenchmarkingSpringApp;
|
||||
import org.springframework.cloud.sleuth.util.ExceptionUtils;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
|
||||
import static org.assertj.core.api.BDDAssertions.then;
|
||||
@@ -69,13 +68,11 @@ public class AnnotationBenchmarks {
|
||||
public void manuallyCreatedSpans(BenchmarkContext context)
|
||||
throws Exception {
|
||||
then(context.sleuth.manualSpan()).isEqualTo("continued");
|
||||
then(ExceptionUtils.getLastException()).isNull();
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
public void spanCreatedWithAnnotations(BenchmarkContext context)
|
||||
throws Exception {
|
||||
then(context.sleuth.newSpan()).isEqualTo("continued");
|
||||
then(ExceptionUtils.getLastException()).isNull();
|
||||
}
|
||||
}
|
||||
@@ -25,14 +25,14 @@ package org.springframework.cloud.sleuth.instrument.web;
|
||||
public final class TraceRequestAttributes {
|
||||
|
||||
/**
|
||||
* Attribute containing a {@link org.springframework.cloud.sleuth.Span} set on a request when it got handled by a Sleuth component.
|
||||
* Attribute containing a Span set on a request when it got handled by a Sleuth component.
|
||||
* If that attribute is set then {@link TraceFilter} will not create a "fallback" server-side span.
|
||||
*/
|
||||
public static final String HANDLED_SPAN_REQUEST_ATTR = TraceRequestAttributes.class.getName()
|
||||
+ ".TRACE_HANDLED";
|
||||
|
||||
/**
|
||||
* Attribute containing a {@link org.springframework.cloud.sleuth.Span} set on a request when it got handled by a Sleuth component.
|
||||
* Attribute containing a Span set on a request when it got handled by a Sleuth component.
|
||||
* If that attribute is set then {@link TraceFilter} will not close a span processed by the Error Controller.
|
||||
*/
|
||||
public static final String ERROR_HANDLED_SPAN_REQUEST_ATTR = TraceRequestAttributes.class.getName()
|
||||
@@ -45,7 +45,7 @@ public final class TraceRequestAttributes {
|
||||
+ ".TRACE_HANDLED_NEW_SPAN";
|
||||
|
||||
/**
|
||||
* Attribute set when the {@link org.springframework.cloud.sleuth.Span} got continued in the {@link TraceFilter}.
|
||||
* Attribute set when the Span got continued in the {@link TraceFilter}.
|
||||
* The Sleuth tracing components will most likely continue the current Span instead of creating a new one.
|
||||
*/
|
||||
public static final String SPAN_CONTINUED_REQUEST_ATTR = TraceRequestAttributes.class.getName()
|
||||
|
||||
Reference in New Issue
Block a user