Detaching async traces only if tracing is still in progress
This commit is contained in:
@@ -45,6 +45,8 @@ public class TraceContinuingCallable<V> extends TraceCallable<V> implements Call
|
||||
|
||||
@Override
|
||||
protected void close(Span span) {
|
||||
getTracer().detach(span);
|
||||
if (getTracer().isTracing()) {
|
||||
getTracer().detach(span);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,12 @@ package org.springframework.cloud.sleuth.instrument.hystrix;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.cloud.sleuth.Span;
|
||||
import org.springframework.cloud.sleuth.TraceKeys;
|
||||
import org.springframework.cloud.sleuth.Tracer;
|
||||
|
||||
import com.netflix.hystrix.strategy.HystrixPlugins;
|
||||
import com.netflix.hystrix.strategy.concurrency.HystrixConcurrencyStrategy;
|
||||
import com.netflix.hystrix.strategy.eventnotifier.HystrixEventNotifier;
|
||||
@@ -26,12 +32,6 @@ import com.netflix.hystrix.strategy.executionhook.HystrixCommandExecutionHook;
|
||||
import com.netflix.hystrix.strategy.metrics.HystrixMetricsPublisher;
|
||||
import com.netflix.hystrix.strategy.properties.HystrixPropertiesStrategy;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.cloud.sleuth.Span;
|
||||
import org.springframework.cloud.sleuth.TraceKeys;
|
||||
import org.springframework.cloud.sleuth.Tracer;
|
||||
|
||||
/**
|
||||
* A {@link HystrixConcurrencyStrategy} that wraps a {@link Callable} in a
|
||||
* {@link Callable} that either starts a new span or continues one if the tracing was
|
||||
@@ -160,7 +160,7 @@ public class SleuthHystrixConcurrencyStrategy extends HystrixConcurrencyStrategy
|
||||
}
|
||||
this.tracer.close(span);
|
||||
}
|
||||
else {
|
||||
else if(this.tracer.isTracing()) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Detaching span since it was continued " + span);
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ class SleuthRxJavaSchedulersHook extends RxJavaSchedulersHook {
|
||||
} finally {
|
||||
if (created) {
|
||||
this.tracer.close(span);
|
||||
} else {
|
||||
} else if (this.tracer.isTracing()) {
|
||||
this.tracer.detach(span);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user