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:
Marcin Grzejszczak
2016-12-30 11:35:55 +01:00
parent 7e393cdf38
commit 7c7660a84f
2 changed files with 12 additions and 2 deletions

View File

@@ -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() {

View File

@@ -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) {