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);
}
Aggregations