use of io.opentracing.ActiveSpan.Continuation in project cxf by apache.
the class AbstractOpenTracingClientProvider method startTraceSpan.
protected TraceScopeHolder<TraceScope> startTraceSpan(final Map<String, List<String>> requestHeaders, URI uri, String method) {
final ActiveSpan parent = tracer.activeSpan();
ActiveSpan span = null;
if (parent == null) {
span = tracer.buildSpan(buildSpanDescription(uri.toString(), method)).startActive();
} else {
span = tracer.buildSpan(buildSpanDescription(uri.toString(), method)).asChildOf(parent).startActive();
}
// Set additional tags
span.setTag(Tags.HTTP_METHOD.getKey(), method);
span.setTag(Tags.HTTP_URL.getKey(), uri.toString());
tracer.inject(span.context(), Builtin.HTTP_HEADERS, new TextMapInjectAdapter(requestHeaders));
// 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.
Continuation continuation = null;
if (isAsyncInvocation()) {
continuation = span.capture();
span.deactivate();
}
return new TraceScopeHolder<TraceScope>(new TraceScope(span, continuation), continuation != null);
}
use of io.opentracing.ActiveSpan.Continuation in project cxf by apache.
the class AbstractOpenTracingProvider method startTraceSpan.
protected TraceScopeHolder<TraceScope> startTraceSpan(final Map<String, List<String>> requestHeaders, URI uri, String method) {
SpanContext parent = tracer.extract(Builtin.HTTP_HEADERS, new TextMapExtractAdapter(requestHeaders.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, this::getFirstValueOrEmpty))));
ActiveSpan scope = null;
if (parent == null) {
scope = tracer.buildSpan(buildSpanDescription(uri.getPath(), method)).startActive();
} else {
scope = tracer.buildSpan(buildSpanDescription(uri.getPath(), method)).asChildOf(parent).startActive();
}
// Set additional tags
scope.setTag(Tags.HTTP_METHOD.getKey(), method);
scope.setTag(Tags.HTTP_URL.getKey(), uri.toString());
// If the service resource is using asynchronous processing mode, the trace
// scope will be closed in another thread and as such should be detached.
Continuation continuation = null;
if (isAsyncResponse()) {
// Do not modify the current context span
continuation = scope.capture();
propagateContinuationSpan(continuation);
scope.deactivate();
}
return new TraceScopeHolder<TraceScope>(new TraceScope(scope, continuation), continuation != null);
}
Aggregations