Added a check for tracing in Trace Filter

This commit is contained in:
Marcin Grzejszczak
2016-12-20 15:56:29 +01:00
parent d2bf1ea776
commit 7ad0803336
2 changed files with 4 additions and 3 deletions

View File

@@ -210,12 +210,13 @@ public class TraceFilter extends GenericFilterBean {
}
recordParentSpan(span);
// in case of a response with exception status will close the span when exception dispatch is handled
if (httpStatusSuccessful(response)) {
// checking if tracing is in progress due to async / different order of view controller processing
if (httpStatusSuccessful(response) && this.tracer.isTracing()) {
if (log.isDebugEnabled()) {
log.debug("Closing the span " + span + " since the response was successful");
}
this.tracer.close(span);
} else if (errorAlreadyHandled(request)) {
} else if (errorAlreadyHandled(request) && this.tracer.isTracing()) {
if (log.isDebugEnabled()) {
log.debug(
"Won't detach the span " + span + " since error has already been handled");

View File

@@ -66,7 +66,7 @@ public class TraceHandlerInterceptor extends HandlerInterceptorAdapter {
boolean continueSpan = getRootSpanFromAttribute(request) != null;
Span span = continueSpan ? getRootSpanFromAttribute(request) : getTracer().createSpan(spanName);
if (log.isDebugEnabled()) {
log.debug("Created new span " + span + " with name [" + spanName + "]");
log.debug("Handling span " + span);
}
addClassMethodTag(handler, span);
addClassNameTag(handler, span);