Search in sources :

Example 1 with ZuulFilterResult

use of com.netflix.zuul.ZuulFilterResult in project incubator-servicecomb-java-chassis by apache.

the class TracePreZuulFilter method runFilter.

@Override
public ZuulFilterResult runFilter() {
    RequestContext ctx = RequestContext.getCurrentContext();
    Span span = clientHandler.handleSend(injector, ctx);
    saveHeadersAsInvocationContext(ctx, span);
    SpanInScope scope = tracer.withSpanInScope(span);
    log.debug("Generated tracing span {} for {}", span, ctx.getRequest().getMethod());
    ctx.getRequest().setAttribute(SpanInScope.class.getName(), scope);
    ZuulFilterResult result = super.runFilter();
    log.debug("Result of Zuul filter is [{}]", result.getStatus());
    if (ExecutionStatus.SUCCESS != result.getStatus()) {
        log.debug("The result of Zuul filter execution was not successful thus will close the current span {}", span);
        clientHandler.handleReceive(ctx.getResponse(), result.getException(), span);
        scope.close();
    }
    return result;
}
Also used : SpanInScope(brave.Tracer.SpanInScope) ZuulFilterResult(com.netflix.zuul.ZuulFilterResult) RequestContext(com.netflix.zuul.context.RequestContext) Span(brave.Span)

Aggregations

Span (brave.Span)1 SpanInScope (brave.Tracer.SpanInScope)1 ZuulFilterResult (com.netflix.zuul.ZuulFilterResult)1 RequestContext (com.netflix.zuul.context.RequestContext)1