Added checks to close / detach only if tracing
without this change during asynchronous communication some components are trying to detach or close spans that were aready detached. This leads to exceptions utils warnings and spans were not closed.
with this change we're adding additional checks to ensure that we're tracing
fixes #447
This commit is contained in:
@@ -74,6 +74,10 @@ public class TraceRunnable implements Runnable {
|
||||
}
|
||||
|
||||
protected void close(Span span) {
|
||||
// race conditions - check #447
|
||||
if (!this.tracer.isTracing()) {
|
||||
this.tracer.continueSpan(span);
|
||||
}
|
||||
this.tracer.close(span);
|
||||
}
|
||||
|
||||
@@ -82,7 +86,10 @@ public class TraceRunnable implements Runnable {
|
||||
}
|
||||
|
||||
protected Span detachSpan(Span span) {
|
||||
return this.tracer.detach(span);
|
||||
if (this.tracer.isTracing()) {
|
||||
return this.tracer.detach(span);
|
||||
}
|
||||
return span;
|
||||
}
|
||||
|
||||
public Tracer getTracer() {
|
||||
|
||||
@@ -116,7 +116,10 @@ public class TraceChannelInterceptor extends AbstractTraceChannelInterceptor {
|
||||
spanFromHeader.logEvent(Span.SERVER_SEND);
|
||||
addErrorTag(ex);
|
||||
}
|
||||
getTracer().detach(spanFromHeader);
|
||||
// related to #447
|
||||
if (getTracer().isTracing()) {
|
||||
getTracer().detach(spanFromHeader);
|
||||
}
|
||||
}
|
||||
|
||||
private void addErrorTag(Exception ex) {
|
||||
|
||||
Reference in New Issue
Block a user