Merge branch '1.1.x'
This commit is contained in:
@@ -181,7 +181,9 @@ public class TraceFilter extends GenericFilterBean {
|
||||
} finally {
|
||||
request.setAttribute(TRACE_ERROR_HANDLED_REQUEST_ATTR, true);
|
||||
addResponseTags(response, null);
|
||||
this.tracer.close(spanFromRequest);
|
||||
if (request.getAttribute(TraceRequestAttributes.ERROR_HANDLED_SPAN_REQUEST_ATTR) == null) {
|
||||
this.tracer.close(spanFromRequest);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,13 @@ public final class TraceRequestAttributes {
|
||||
public static final String HANDLED_SPAN_REQUEST_ATTR = TraceRequestAttributes.class.getName()
|
||||
+ ".TRACE_HANDLED";
|
||||
|
||||
/**
|
||||
* Attribute containing a {@link org.springframework.cloud.sleuth.Span} set on a request when it got handled by a Sleuth component.
|
||||
* If that attribute is set then {@link TraceFilter} will not close a span processed by the Error Controller.
|
||||
*/
|
||||
public static final String ERROR_HANDLED_SPAN_REQUEST_ATTR = TraceRequestAttributes.class.getName()
|
||||
+ ".ERROR_TRACE_HANDLED";
|
||||
|
||||
/**
|
||||
* Set if Handler interceptor has executed some logic
|
||||
*/
|
||||
|
||||
@@ -18,15 +18,15 @@ package org.springframework.cloud.sleuth.instrument.zuul;
|
||||
|
||||
import java.lang.invoke.MethodHandles;
|
||||
|
||||
import com.netflix.zuul.ZuulFilter;
|
||||
import com.netflix.zuul.context.RequestContext;
|
||||
|
||||
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.zuul.ZuulFilter;
|
||||
import com.netflix.zuul.context.RequestContext;
|
||||
|
||||
/**8
|
||||
* A post request {@link ZuulFilter} that publishes an event upon start of the filtering
|
||||
*
|
||||
@@ -52,6 +52,7 @@ public class TracePostZuulFilter extends ZuulFilter {
|
||||
|
||||
@Override
|
||||
public Object run() {
|
||||
this.tracer.continueSpan(getCurrentSpan());
|
||||
// TODO: the client sent event should come from the client not the filter!
|
||||
getCurrentSpan().logEvent(Span.CLIENT_RECV);
|
||||
if (log.isDebugEnabled()) {
|
||||
|
||||
@@ -19,11 +19,6 @@ package org.springframework.cloud.sleuth.instrument.zuul;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.net.URI;
|
||||
|
||||
import com.netflix.zuul.ExecutionStatus;
|
||||
import com.netflix.zuul.ZuulFilter;
|
||||
import com.netflix.zuul.ZuulFilterResult;
|
||||
import com.netflix.zuul.context.RequestContext;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.cloud.sleuth.instrument.web.HttpSpanInjector;
|
||||
@@ -32,6 +27,11 @@ import org.springframework.cloud.sleuth.Tracer;
|
||||
import org.springframework.cloud.sleuth.instrument.web.HttpTraceKeysInjector;
|
||||
import org.springframework.cloud.sleuth.instrument.web.TraceRequestAttributes;
|
||||
|
||||
import com.netflix.zuul.ExecutionStatus;
|
||||
import com.netflix.zuul.ZuulFilter;
|
||||
import com.netflix.zuul.ZuulFilterResult;
|
||||
import com.netflix.zuul.context.RequestContext;
|
||||
|
||||
/**
|
||||
* A pre request {@link ZuulFilter} that sets tracing related headers on the request
|
||||
* from the current span. We're doing so to ensure tracing propagates to the next hop.
|
||||
@@ -99,6 +99,7 @@ public class TracePreZuulFilter extends ZuulFilter {
|
||||
// TraceFilter will not create the "fallback" span
|
||||
private void markRequestAsHandled(RequestContext ctx) {
|
||||
ctx.getRequest().setAttribute(TraceRequestAttributes.HANDLED_SPAN_REQUEST_ATTR, "true");
|
||||
ctx.getRequest().setAttribute(TraceRequestAttributes.ERROR_HANDLED_SPAN_REQUEST_ATTR, "true");
|
||||
}
|
||||
|
||||
private Span getCurrentSpan() {
|
||||
@@ -115,4 +116,5 @@ public class TracePreZuulFilter extends ZuulFilter {
|
||||
public int filterOrder() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user