Search in sources :

Example 6 with Span

use of org.apache.htrace.core.Span in project cxf by apache.

the class AbstractHTraceClientProvider method startTraceSpan.

protected TraceScopeHolder<TraceScope> startTraceSpan(final Map<String, List<String>> requestHeaders, String path, String method) {
    Span span = Tracer.getCurrentSpan();
    TraceScope traceScope = null;
    if (span == null) {
        traceScope = tracer.newScope(buildSpanDescription(path, method));
        span = traceScope.getSpan();
    }
    if (span != null) {
        final String spanIdHeader = getSpanIdHeader();
        // Transfer tracing headers into the response headers
        requestHeaders.put(spanIdHeader, Collections.singletonList(span.getSpanId().toString()));
    }
    // In case of asynchronous client invocation, the span should be detached as JAX-RS
    // client request / response filters are going to be executed in different threads.
    boolean detached = false;
    if (isAsyncInvocation() && traceScope != null) {
        traceScope.detach();
        detached = true;
    }
    return new TraceScopeHolder<TraceScope>(traceScope, detached);
}
Also used : TraceScope(org.apache.htrace.core.TraceScope) Span(org.apache.htrace.core.Span)

Aggregations

Span (org.apache.htrace.core.Span)6 TraceScope (org.apache.htrace.core.TraceScope)3 List (java.util.List)2 IOException (java.io.IOException)1 ClosedChannelException (java.nio.channels.ClosedChannelException)1 CallerContext (org.apache.hadoop.ipc.CallerContext)1