diff --git a/pom.xml b/pom.xml
index ed81c9fbb..530ae5642 100644
--- a/pom.xml
+++ b/pom.xml
@@ -272,9 +272,9 @@
Elmhurst.BUILD-SNAPSHOT
2.0.0.BUILD-SNAPSHOT
2.0.0.BUILD-SNAPSHOT
- 4.18.2
+ 4.19.0
- 2.6.1
+ 2.7.0
2.0.0.RELEASE
diff --git a/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/ErrorParser.java b/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/ErrorParser.java
deleted file mode 100644
index 8133ef544..000000000
--- a/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/ErrorParser.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright 2013-2018 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;
-
-import brave.SpanCustomizer;
-
-/**
- * Contract for hooking into process of adding error response tags.
- * This interface is only called when an exception is thrown upon receiving a response.
- * (e.g. a response of 500 may not be an exception).
- *
- * @author Marcin Grzejszczak
- * @since 1.2.1
- */
-public interface ErrorParser {
-
- /**
- * Allows setting of tags when an exception was thrown when the response was received.
- *
- * @param span - current span in context
- * @param error - error that was thrown upon receiving a response
- */
- void parseErrorTags(SpanCustomizer span, Throwable error);
-}
diff --git a/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/ExceptionMessageErrorParser.java b/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/ExceptionMessageErrorParser.java
deleted file mode 100644
index ea6ba3749..000000000
--- a/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/ExceptionMessageErrorParser.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright 2013-2018 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;
-
-import brave.SpanCustomizer;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * {@link ErrorParser} that sets the error tag for an exportable span.
- *
- * @author Marcin Grzejszczak
- * @since 1.2.1
- */
-public class ExceptionMessageErrorParser implements ErrorParser {
-
- private static final Log log = LogFactory.getLog(ExceptionMessageErrorParser.class);
-
- @Override
- public void parseErrorTags(SpanCustomizer span, Throwable error) {
- if (span != null && error != null) {
- String errorMsg = getExceptionMessage(error);
- if (log.isDebugEnabled()) {
- log.debug("Adding an error tag [" + errorMsg + "] to span " + span);
- }
- span.tag("error", errorMsg);
- }
- }
-
- private String getExceptionMessage(Throwable e) {
- return e.getMessage() != null ? e.getMessage() : e.toString();
- }
-}
diff --git a/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/annotation/SleuthAdvisorConfig.java b/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/annotation/SleuthAdvisorConfig.java
index e12b65f79..6c58c19a4 100644
--- a/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/annotation/SleuthAdvisorConfig.java
+++ b/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/annotation/SleuthAdvisorConfig.java
@@ -37,7 +37,6 @@ import org.springframework.aop.support.annotation.AnnotationClassFilter;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
-import org.springframework.cloud.sleuth.ErrorParser;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.util.ReflectionUtils;
import org.springframework.util.StringUtils;
@@ -177,7 +176,6 @@ class SleuthInterceptor implements IntroductionInterceptor, BeanFactoryAware {
private NewSpanParser newSpanParser;
private Tracer tracer;
private SpanTagAnnotationHandler spanTagAnnotationHandler;
- private ErrorParser errorParser;
@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
@@ -213,7 +211,7 @@ class SleuthInterceptor implements IntroductionInterceptor, BeanFactoryAware {
if (hasLog) {
logEvent(span, log + ".afterFailure");
}
- errorParser().parseErrorTags(span.customizer(), e);
+ span.error(e);
throw e;
} finally {
if (hasLog) {
@@ -268,13 +266,6 @@ class SleuthInterceptor implements IntroductionInterceptor, BeanFactoryAware {
return this.spanTagAnnotationHandler;
}
- private ErrorParser errorParser() {
- if (this.errorParser == null) {
- this.errorParser = this.beanFactory.getBean(ErrorParser.class);
- }
- return this.errorParser;
- }
-
@Override public boolean implementsInterface(Class> intf) {
return true;
}
diff --git a/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/autoconfig/TraceAutoConfiguration.java b/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/autoconfig/TraceAutoConfiguration.java
index fcac42341..4825e05bf 100644
--- a/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/autoconfig/TraceAutoConfiguration.java
+++ b/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/autoconfig/TraceAutoConfiguration.java
@@ -20,6 +20,7 @@ import java.util.ArrayList;
import java.util.List;
import brave.CurrentSpanCustomizer;
+import brave.ErrorParser;
import brave.Tracer;
import brave.Tracing;
import brave.context.log4j2.ThreadContextCurrentTraceContext;
@@ -34,8 +35,6 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
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.ErrorParser;
-import org.springframework.cloud.sleuth.ExceptionMessageErrorParser;
import org.springframework.cloud.sleuth.SpanAdjuster;
import org.springframework.cloud.sleuth.SpanNamer;
import org.springframework.cloud.sleuth.TraceKeys;
@@ -66,9 +65,13 @@ public class TraceAutoConfiguration {
Propagation.Factory factory,
CurrentTraceContext currentTraceContext,
Reporter reporter,
- Sampler sampler, SleuthProperties sleuthProperties) {
+ Sampler sampler,
+ ErrorParser errorParser,
+ SleuthProperties sleuthProperties
+ ) {
return Tracing.newBuilder()
.sampler(sampler)
+ .errorParser(errorParser)
.localServiceName(serviceName)
.propagationFactory(factory)
.currentTraceContext(currentTraceContext)
@@ -143,8 +146,8 @@ public class TraceAutoConfiguration {
@Bean
@ConditionalOnMissingBean
- ErrorParser sleuthErrorParser() {
- return new ExceptionMessageErrorParser();
+ ErrorParser errorParser() {
+ return new ErrorParser();
}
@Bean
diff --git a/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/async/LazyTraceExecutor.java b/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/async/LazyTraceExecutor.java
index 97bc50d38..926d44597 100644
--- a/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/async/LazyTraceExecutor.java
+++ b/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/async/LazyTraceExecutor.java
@@ -18,14 +18,12 @@ package org.springframework.cloud.sleuth.instrument.async;
import java.util.concurrent.Executor;
-import brave.Tracer;
+import brave.Tracing;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.cloud.sleuth.DefaultSpanNamer;
-import org.springframework.cloud.sleuth.ErrorParser;
-import org.springframework.cloud.sleuth.ExceptionMessageErrorParser;
import org.springframework.cloud.sleuth.SpanNamer;
/**
@@ -38,11 +36,10 @@ public class LazyTraceExecutor implements Executor {
private static final Log log = LogFactory.getLog(LazyTraceExecutor.class);
- private Tracer tracer;
+ private Tracing tracing;
private final BeanFactory beanFactory;
private final Executor delegate;
private SpanNamer spanNamer;
- private ErrorParser errorParser;
public LazyTraceExecutor(BeanFactory beanFactory, Executor delegate) {
this.beanFactory = beanFactory;
@@ -51,16 +48,16 @@ public class LazyTraceExecutor implements Executor {
@Override
public void execute(Runnable command) {
- if (this.tracer == null) {
+ if (this.tracing == null) {
try {
- this.tracer = this.beanFactory.getBean(Tracer.class);
+ this.tracing = this.beanFactory.getBean(Tracing.class);
}
catch (NoSuchBeanDefinitionException e) {
this.delegate.execute(command);
return;
}
}
- this.delegate.execute(new TraceRunnable(this.tracer, spanNamer(), errorParser(), command));
+ this.delegate.execute(new TraceRunnable(this.tracing, spanNamer(), command));
}
// due to some race conditions trace keys might not be ready yet
@@ -76,19 +73,4 @@ public class LazyTraceExecutor implements Executor {
}
return this.spanNamer;
}
-
- // due to some race conditions trace keys might not be ready yet
- private ErrorParser errorParser() {
- if (this.errorParser == null) {
- try {
- this.errorParser = this.beanFactory.getBean(ErrorParser.class);
- }
- catch (NoSuchBeanDefinitionException e) {
- log.warn("ErrorParser bean not found - will provide a manually created instance");
- return new ExceptionMessageErrorParser();
- }
- }
- return this.errorParser;
- }
-
}
diff --git a/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/async/LazyTraceThreadPoolTaskExecutor.java b/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/async/LazyTraceThreadPoolTaskExecutor.java
index 4355397ff..b6a5320f6 100644
--- a/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/async/LazyTraceThreadPoolTaskExecutor.java
+++ b/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/async/LazyTraceThreadPoolTaskExecutor.java
@@ -22,14 +22,12 @@ import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
-import brave.Tracer;
+import brave.Tracing;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.cloud.sleuth.DefaultSpanNamer;
-import org.springframework.cloud.sleuth.ErrorParser;
-import org.springframework.cloud.sleuth.ExceptionMessageErrorParser;
import org.springframework.cloud.sleuth.SpanNamer;
import org.springframework.core.task.TaskDecorator;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
@@ -46,11 +44,10 @@ public class LazyTraceThreadPoolTaskExecutor extends ThreadPoolTaskExecutor {
private static final Log log = LogFactory.getLog(LazyTraceThreadPoolTaskExecutor.class);
- private Tracer tracer;
private final BeanFactory beanFactory;
private final ThreadPoolTaskExecutor delegate;
+ private Tracing tracing;
private SpanNamer spanNamer;
- private ErrorParser errorParser;
public LazyTraceThreadPoolTaskExecutor(BeanFactory beanFactory,
ThreadPoolTaskExecutor delegate) {
@@ -60,32 +57,32 @@ public class LazyTraceThreadPoolTaskExecutor extends ThreadPoolTaskExecutor {
@Override
public void execute(Runnable task) {
- this.delegate.execute(new TraceRunnable(tracer(), spanNamer(), errorParser(), task));
+ this.delegate.execute(new TraceRunnable(tracing(), spanNamer(), task));
}
@Override
public void execute(Runnable task, long startTimeout) {
- this.delegate.execute(new TraceRunnable(tracer(), spanNamer(), errorParser(), task), startTimeout);
+ this.delegate.execute(new TraceRunnable(tracing(), spanNamer(), task), startTimeout);
}
@Override
public Future> submit(Runnable task) {
- return this.delegate.submit(new TraceRunnable(tracer(), spanNamer(), errorParser(), task));
+ return this.delegate.submit(new TraceRunnable(tracing(), spanNamer(), task));
}
@Override
public Future submit(Callable task) {
- return this.delegate.submit(new TraceCallable<>(tracer(), spanNamer(), errorParser(), task));
+ return this.delegate.submit(new TraceCallable<>(tracing(), spanNamer(), task));
}
@Override
public ListenableFuture> submitListenable(Runnable task) {
- return this.delegate.submitListenable(new TraceRunnable(tracer(), spanNamer(), errorParser(), task));
+ return this.delegate.submitListenable(new TraceRunnable(tracing(), spanNamer(), task));
}
@Override
public ListenableFuture submitListenable(Callable task) {
- return this.delegate.submitListenable(new TraceCallable<>(tracer(), spanNamer(), errorParser(), task));
+ return this.delegate.submitListenable(new TraceCallable<>(tracing(), spanNamer(), task));
}
@Override public boolean prefersShortLivedTasks() {
@@ -229,11 +226,11 @@ public class LazyTraceThreadPoolTaskExecutor extends ThreadPoolTaskExecutor {
this.delegate.setTaskDecorator(taskDecorator);
}
- private Tracer tracer() {
- if (this.tracer == null) {
- this.tracer = this.beanFactory.getBean(Tracer.class);
+ private Tracing tracing() {
+ if (this.tracing == null) {
+ this.tracing = this.beanFactory.getBean(Tracing.class);
}
- return this.tracer;
+ return this.tracing;
}
private SpanNamer spanNamer() {
@@ -248,17 +245,4 @@ public class LazyTraceThreadPoolTaskExecutor extends ThreadPoolTaskExecutor {
}
return this.spanNamer;
}
-
- private ErrorParser errorParser() {
- if (this.errorParser == null) {
- try {
- this.errorParser = this.beanFactory.getBean(ErrorParser.class);
- }
- catch (NoSuchBeanDefinitionException e) {
- log.warn("ErrorParser bean not found - will provide a manually created instance");
- return new ExceptionMessageErrorParser();
- }
- }
- return this.errorParser;
- }
}
diff --git a/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/async/TraceCallable.java b/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/async/TraceCallable.java
index 7b08e6fda..d40d1e4bf 100644
--- a/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/async/TraceCallable.java
+++ b/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/async/TraceCallable.java
@@ -16,11 +16,12 @@
package org.springframework.cloud.sleuth.instrument.async;
+import brave.ScopedSpan;
+import brave.Tracing;
+import brave.propagation.TraceContext;
import java.util.concurrent.Callable;
-import brave.Span;
import brave.Tracer;
-import org.springframework.cloud.sleuth.ErrorParser;
import org.springframework.cloud.sleuth.SpanNamer;
/**
@@ -42,31 +43,29 @@ public class TraceCallable implements Callable {
private final Tracer tracer;
private final Callable delegate;
- private final Span span;
- private final ErrorParser errorParser;
+ private final TraceContext parent;
+ private final String spanName;
- public TraceCallable(Tracer tracer, SpanNamer spanNamer, ErrorParser errorParser, Callable delegate) {
- this(tracer, spanNamer, errorParser, delegate, null);
+ public TraceCallable(Tracing tracing, SpanNamer spanNamer, Callable delegate) {
+ this(tracing, spanNamer, delegate, null);
}
- public TraceCallable(Tracer tracer, SpanNamer spanNamer, ErrorParser errorParser, Callable delegate, String name) {
- this.tracer = tracer;
+ public TraceCallable(Tracing tracing, SpanNamer spanNamer, Callable delegate, String name) {
+ this.tracer = tracing.tracer();
this.delegate = delegate;
- String spanName = name != null ? name : spanNamer.name(delegate, DEFAULT_SPAN_NAME);
- this.span = this.tracer.nextSpan().name(spanName);
- this.errorParser = errorParser;
+ this.parent = tracing.currentTraceContext().get();
+ this.spanName = name != null ? name : spanNamer.name(delegate, DEFAULT_SPAN_NAME);
}
@Override public V call() throws Exception {
- Throwable error = null;
- try (Tracer.SpanInScope ws = this.tracer.withSpanInScope(this.span.start())) {
+ ScopedSpan span = this.tracer.startScopedSpanWithParent(this.spanName, this.parent);
+ try {
return this.delegate.call();
} catch (Exception | Error e) {
- error = e;
+ span.error(e);
throw e;
} finally {
- this.errorParser.parseErrorTags(this.span.customizer(), error);
- this.span.finish();
+ span.finish();
}
}
}
diff --git a/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/async/TraceRunnable.java b/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/async/TraceRunnable.java
index 111859ea5..af0b8e1da 100644
--- a/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/async/TraceRunnable.java
+++ b/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/async/TraceRunnable.java
@@ -16,10 +16,10 @@
package org.springframework.cloud.sleuth.instrument.async;
-import brave.Span;
+import brave.ScopedSpan;
import brave.Tracer;
-import brave.Tracer.SpanInScope;
-import org.springframework.cloud.sleuth.ErrorParser;
+import brave.Tracing;
+import brave.propagation.TraceContext;
import org.springframework.cloud.sleuth.SpanNamer;
/**
@@ -41,32 +41,30 @@ public class TraceRunnable implements Runnable {
private final Tracer tracer;
private final Runnable delegate;
- private final Span span;
- private final ErrorParser errorParser;
+ private final TraceContext parent;
+ private final String spanName;
- public TraceRunnable(Tracer tracer, SpanNamer spanNamer, ErrorParser errorParser, Runnable delegate) {
- this(tracer, spanNamer, errorParser, delegate, null);
+ public TraceRunnable(Tracing tracing, SpanNamer spanNamer, Runnable delegate) {
+ this(tracing, spanNamer, delegate, null);
}
- public TraceRunnable(Tracer tracer, SpanNamer spanNamer, ErrorParser errorParser, Runnable delegate, String name) {
- this.tracer = tracer;
+ public TraceRunnable(Tracing tracing, SpanNamer spanNamer, Runnable delegate, String name) {
+ this.tracer = tracing.tracer();
this.delegate = delegate;
- String spanName = name != null ? name : spanNamer.name(delegate, DEFAULT_SPAN_NAME);
- this.span = this.tracer.nextSpan().name(spanName);
- this.errorParser = errorParser;
+ this.parent = tracing.currentTraceContext().get();
+ this.spanName = name != null ? name : spanNamer.name(delegate, DEFAULT_SPAN_NAME);
}
@Override
public void run() {
- Throwable error = null;
- try (SpanInScope ws = this.tracer.withSpanInScope(this.span.start())) {
- this.delegate.run();
- } catch (RuntimeException | Error e) {
- error = e;
- throw e;
- } finally {
- this.errorParser.parseErrorTags(this.span.customizer(), error);
- this.span.finish();
- }
+ ScopedSpan span = this.tracer.startScopedSpanWithParent(this.spanName, this.parent);
+ try {
+ this.delegate.run();
+ } catch (Exception | Error e) {
+ span.error(e);
+ throw e;
+ } finally {
+ span.finish();
+ }
}
}
diff --git a/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/async/TraceableExecutorService.java b/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/async/TraceableExecutorService.java
index bc3893818..56b47bee5 100644
--- a/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/async/TraceableExecutorService.java
+++ b/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/async/TraceableExecutorService.java
@@ -25,9 +25,8 @@ import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
-import brave.Tracer;
+import brave.Tracing;
import org.springframework.beans.factory.BeanFactory;
-import org.springframework.cloud.sleuth.ErrorParser;
import org.springframework.cloud.sleuth.SpanNamer;
/**
@@ -38,11 +37,10 @@ import org.springframework.cloud.sleuth.SpanNamer;
*/
public class TraceableExecutorService implements ExecutorService {
final ExecutorService delegate;
- Tracer tracer;
private final String spanName;
+ Tracing tracing;
SpanNamer spanNamer;
BeanFactory beanFactory;
- ErrorParser errorParser;
public TraceableExecutorService(BeanFactory beanFactory, final ExecutorService delegate) {
this(beanFactory, delegate, null);
@@ -56,7 +54,7 @@ public class TraceableExecutorService implements ExecutorService {
@Override
public void execute(Runnable command) {
- final Runnable r = new TraceRunnable(tracer(), spanNamer(), errorParser(), command, this.spanName);
+ final Runnable r = new TraceRunnable(tracing(), spanNamer(), command, this.spanName);
this.delegate.execute(r);
}
@@ -87,19 +85,19 @@ public class TraceableExecutorService implements ExecutorService {
@Override
public Future submit(Callable task) {
- Callable c = new TraceCallable<>(tracer(), spanNamer(), errorParser(), task, this.spanName);
+ Callable c = new TraceCallable<>(tracing(), spanNamer(), task, this.spanName);
return this.delegate.submit(c);
}
@Override
public Future submit(Runnable task, T result) {
- Runnable r = new TraceRunnable(tracer(), spanNamer(), errorParser(), task, this.spanName);
+ Runnable r = new TraceRunnable(tracing(), spanNamer(), task, this.spanName);
return this.delegate.submit(r, result);
}
@Override
public Future> submit(Runnable task) {
- Runnable r = new TraceRunnable(tracer(), spanNamer(), errorParser(), task, this.spanName);
+ Runnable r = new TraceRunnable(tracing(), spanNamer(), task, this.spanName);
return this.delegate.submit(r);
}
@@ -129,17 +127,17 @@ public class TraceableExecutorService implements ExecutorService {
List> ts = new ArrayList<>();
for (Callable task : tasks) {
if (!(task instanceof TraceCallable)) {
- ts.add(new TraceCallable<>(tracer(), spanNamer(), errorParser(), task, this.spanName));
+ ts.add(new TraceCallable<>(tracing(), spanNamer(), task, this.spanName));
}
}
return ts;
}
- Tracer tracer() {
- if (this.tracer == null && this.beanFactory != null) {
- this.tracer = this.beanFactory.getBean(Tracer.class);
+ Tracing tracing() {
+ if (this.tracing == null && this.beanFactory != null) {
+ this.tracing = this.beanFactory.getBean(Tracing.class);
}
- return this.tracer;
+ return this.tracing;
}
SpanNamer spanNamer() {
@@ -148,11 +146,4 @@ public class TraceableExecutorService implements ExecutorService {
}
return this.spanNamer;
}
-
- ErrorParser errorParser() {
- if (this.errorParser == null) {
- this.errorParser = this.beanFactory.getBean(ErrorParser.class);
- }
- return this.errorParser;
- }
}
diff --git a/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/async/TraceableScheduledExecutorService.java b/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/async/TraceableScheduledExecutorService.java
index 6156674e5..0fb22cf33 100644
--- a/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/async/TraceableScheduledExecutorService.java
+++ b/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/async/TraceableScheduledExecutorService.java
@@ -42,25 +42,25 @@ public class TraceableScheduledExecutorService extends TraceableExecutorService
@Override
public ScheduledFuture> schedule(Runnable command, long delay, TimeUnit unit) {
- Runnable r = new TraceRunnable(tracer(), spanNamer(), errorParser(), command);
+ Runnable r = new TraceRunnable(tracing(), spanNamer(), command);
return getScheduledExecutorService().schedule(r, delay, unit);
}
@Override
public ScheduledFuture schedule(Callable callable, long delay, TimeUnit unit) {
- Callable c = new TraceCallable<>(tracer(), spanNamer(), errorParser(), callable);
+ Callable c = new TraceCallable<>(tracing(), spanNamer(), callable);
return getScheduledExecutorService().schedule(c, delay, unit);
}
@Override
public ScheduledFuture> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit) {
- Runnable r = new TraceRunnable(tracer(), spanNamer(), errorParser(), command);
+ Runnable r = new TraceRunnable(tracing(), spanNamer(), command);
return getScheduledExecutorService().scheduleAtFixedRate(r, initialDelay, period, unit);
}
@Override
public ScheduledFuture> scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit) {
- Runnable r = new TraceRunnable(tracer(), spanNamer(), errorParser(), command);
+ Runnable r = new TraceRunnable(tracing(), spanNamer(), command);
return getScheduledExecutorService().scheduleWithFixedDelay(r, initialDelay, delay, unit);
}
diff --git a/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/hystrix/SleuthHystrixAutoConfiguration.java b/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/hystrix/SleuthHystrixAutoConfiguration.java
index 724703ca4..a341757ab 100644
--- a/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/hystrix/SleuthHystrixAutoConfiguration.java
+++ b/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/hystrix/SleuthHystrixAutoConfiguration.java
@@ -16,13 +16,11 @@
package org.springframework.cloud.sleuth.instrument.hystrix;
-import brave.Tracer;
import brave.Tracing;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
-import org.springframework.cloud.sleuth.ErrorParser;
import org.springframework.cloud.sleuth.SpanNamer;
import org.springframework.cloud.sleuth.autoconfig.TraceAutoConfiguration;
import org.springframework.context.annotation.Bean;
@@ -46,10 +44,9 @@ import com.netflix.hystrix.HystrixCommand;
@ConditionalOnProperty(value = "spring.sleuth.hystrix.strategy.enabled", matchIfMissing = true)
public class SleuthHystrixAutoConfiguration {
- @Bean SleuthHystrixConcurrencyStrategy sleuthHystrixConcurrencyStrategy(Tracer tracer,
- SpanNamer spanNamer, ErrorParser errorParser) {
- return new SleuthHystrixConcurrencyStrategy(tracer, spanNamer,
- errorParser);
+ @Bean SleuthHystrixConcurrencyStrategy sleuthHystrixConcurrencyStrategy(Tracing tracing,
+ SpanNamer spanNamer) {
+ return new SleuthHystrixConcurrencyStrategy(tracing, spanNamer);
}
}
diff --git a/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/hystrix/SleuthHystrixConcurrencyStrategy.java b/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/hystrix/SleuthHystrixConcurrencyStrategy.java
index 48a329a4b..39237001e 100644
--- a/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/hystrix/SleuthHystrixConcurrencyStrategy.java
+++ b/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/hystrix/SleuthHystrixConcurrencyStrategy.java
@@ -21,7 +21,7 @@ import java.util.concurrent.Callable;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
-import brave.Tracer;
+import brave.Tracing;
import com.netflix.hystrix.HystrixThreadPoolKey;
import com.netflix.hystrix.HystrixThreadPoolProperties;
import com.netflix.hystrix.strategy.HystrixPlugins;
@@ -35,7 +35,6 @@ import com.netflix.hystrix.strategy.properties.HystrixPropertiesStrategy;
import com.netflix.hystrix.strategy.properties.HystrixProperty;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.springframework.cloud.sleuth.ErrorParser;
import org.springframework.cloud.sleuth.SpanNamer;
import org.springframework.cloud.sleuth.instrument.async.TraceCallable;
@@ -53,16 +52,13 @@ public class SleuthHystrixConcurrencyStrategy extends HystrixConcurrencyStrategy
private static final Log log = LogFactory
.getLog(SleuthHystrixConcurrencyStrategy.class);
- private final Tracer tracer;
+ private final Tracing tracing;
private final SpanNamer spanNamer;
- private final ErrorParser errorParser;
private HystrixConcurrencyStrategy delegate;
- public SleuthHystrixConcurrencyStrategy(Tracer tracer,
- SpanNamer spanNamer, ErrorParser errorParser) {
- this.tracer = tracer;
+ public SleuthHystrixConcurrencyStrategy(Tracing tracing, SpanNamer spanNamer) {
+ this.tracing = tracing;
this.spanNamer = spanNamer;
- this.errorParser = errorParser;
try {
this.delegate = HystrixPlugins.getInstance().getConcurrencyStrategy();
if (this.delegate instanceof SleuthHystrixConcurrencyStrategy) {
@@ -114,8 +110,8 @@ public class SleuthHystrixConcurrencyStrategy extends HystrixConcurrencyStrategy
if (wrappedCallable instanceof TraceCallable) {
return wrappedCallable;
}
- return new TraceCallable<>(this.tracer, this.spanNamer,
- this.errorParser, wrappedCallable, HYSTRIX_COMPONENT);
+ return new TraceCallable<>(this.tracing, this.spanNamer,
+ wrappedCallable, HYSTRIX_COMPONENT);
}
@Override
diff --git a/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/web/SleuthHttpServerParser.java b/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/web/SleuthHttpServerParser.java
index 9c943aea2..d04efc335 100644
--- a/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/web/SleuthHttpServerParser.java
+++ b/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/web/SleuthHttpServerParser.java
@@ -16,13 +16,13 @@
package org.springframework.cloud.sleuth.instrument.web;
+import brave.ErrorParser;
import javax.servlet.http.HttpServletResponse;
import brave.SpanCustomizer;
import brave.http.HttpAdapter;
import brave.http.HttpClientParser;
import brave.http.HttpServerParser;
-import org.springframework.cloud.sleuth.ErrorParser;
import org.springframework.cloud.sleuth.TraceKeys;
/**
@@ -43,6 +43,10 @@ class SleuthHttpServerParser extends HttpServerParser {
this.traceKeys = traceKeys;
}
+ @Override protected ErrorParser errorParser() {
+ return this.errorParser;
+ }
+
@Override protected String spanName(HttpAdapter adapter,
Req req) {
return this.clientParser.spanName(adapter, req);
@@ -53,11 +57,6 @@ class SleuthHttpServerParser extends HttpServerParser {
this.clientParser.request(adapter, req, customizer);
}
- @Override
- protected void error(Integer httpStatus, Throwable error, SpanCustomizer customizer) {
- this.errorParser.parseErrorTags(customizer, error);
- }
-
@Override
public void response(HttpAdapter, Resp> adapter, Resp res, Throwable error,
SpanCustomizer customizer) {
diff --git a/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/web/TraceHttpAutoConfiguration.java b/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/web/TraceHttpAutoConfiguration.java
index 466d16517..f8f2cfb71 100644
--- a/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/web/TraceHttpAutoConfiguration.java
+++ b/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/web/TraceHttpAutoConfiguration.java
@@ -16,6 +16,7 @@
package org.springframework.cloud.sleuth.instrument.web;
+import brave.ErrorParser;
import brave.Tracing;
import brave.http.HttpAdapter;
import brave.http.HttpClientParser;
@@ -28,7 +29,6 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
-import org.springframework.cloud.sleuth.ErrorParser;
import org.springframework.cloud.sleuth.TraceKeys;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -88,8 +88,12 @@ public class TraceHttpAutoConfiguration {
@ConditionalOnProperty(name = "spring.sleuth.http.legacy.enabled",
havingValue = "false", matchIfMissing = true)
@ConditionalOnMissingBean
- HttpClientParser httpClientParser() {
- return new HttpClientParser();
+ HttpClientParser httpClientParser(ErrorParser errorParser) {
+ return new HttpClientParser() {
+ @Override protected ErrorParser errorParser() {
+ return errorParser;
+ }
+ };
}
@Bean
diff --git a/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/web/TraceWebAspect.java b/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/web/TraceWebAspect.java
index fbb89bda7..31657a6f2 100644
--- a/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/web/TraceWebAspect.java
+++ b/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/web/TraceWebAspect.java
@@ -19,13 +19,13 @@ package org.springframework.cloud.sleuth.instrument.web;
import java.lang.reflect.Field;
import java.util.concurrent.Callable;
-import brave.Tracer;
+import brave.Tracing;
+import brave.propagation.TraceContext;
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.SpanNamer;
import org.springframework.cloud.sleuth.instrument.async.TraceCallable;
import org.springframework.web.context.request.async.WebAsyncTask;
@@ -44,7 +44,7 @@ import org.springframework.web.context.request.async.WebAsyncTask;
*
*
* For controllers an around aspect is created that wraps the {@link Callable#call()}
- * method execution in {@link org.springframework.cloud.sleuth.TraceCallable}
+ * method execution in {@link TraceCallable}
*
*
* This aspect will continue a span created by the TraceFilter. It will not create
@@ -67,15 +67,12 @@ public class TraceWebAspect {
private static final Log log = org.apache.commons.logging.LogFactory
.getLog(TraceWebAspect.class);
- private final Tracer tracer;
+ private final Tracing tracing;
private final SpanNamer spanNamer;
- private final ErrorParser errorParser;
- public TraceWebAspect(Tracer tracer, SpanNamer spanNamer,
- ErrorParser errorParser) {
- this.tracer = tracer;
+ public TraceWebAspect(Tracing tracing, SpanNamer spanNamer) {
+ this.tracing = tracing;
this.spanNamer = spanNamer;
- this.errorParser = errorParser;
}
@Pointcut("@within(org.springframework.web.bind.annotation.RestController)")
@@ -100,33 +97,33 @@ public class TraceWebAspect {
@SuppressWarnings("unchecked")
public Object wrapWithCorrelationId(ProceedingJoinPoint pjp) throws Throwable {
Callable