/** * Like {@link #handleSend(TraceContext.Injector, Object)}, except for when the carrier of trace * data is not the same as the request. * * @see HttpClientParser#request(HttpAdapter, Object, SpanCustomizer) */ public <C> Span handleSend(TraceContext.Injector<C> injector, C carrier, Req request) { return handleSend(injector, carrier, request, nextSpan(request)); }
@Override public CloseableHttpResponse execute(HttpRoute route, HttpRequestWrapper request, HttpClientContext clientContext, HttpExecutionAware execAware) throws IOException, HttpException { Span span = handler.nextSpan(request); CloseableHttpResponse response = null; Throwable error = null; try (SpanInScope ws = tracer.withSpanInScope(span)) { return response = protocolExec.execute(route, request, clientContext, execAware); } catch (IOException | HttpException | RuntimeException | Error e) { error = e; throw e; } finally { handler.handleReceive(response, error, span); } } }
@Override public void process(HttpRequest request, HttpContext context) { HttpHost host = HttpClientContext.adapt(context).getTargetHost(); TraceContext parent = (TraceContext) context.getAttribute(TraceContext.class.getName()); Span span; try (Scope scope = currentTraceContext.maybeScope(parent)) { span = handler.nextSpan(request); } HttpRequestWrapper requestWrapper = HttpRequestWrapper.wrap(request, host); parseTargetAddress(requestWrapper, span); handler.handleSend(injector, request, requestWrapper, span); context.setAttribute(Span.class.getName(), span); context.setAttribute(Scope.class.getName(), currentTraceContext.newScope(span.context())); } }
@Override public CloseableHttpResponse execute(HttpRoute route, HttpRequestWrapper request, HttpClientContext clientContext, HttpExecutionAware execAware) throws IOException, HttpException { Span span = handler.nextSpan(request); CloseableHttpResponse response = null; Throwable error = null; try (SpanInScope ws = tracer.withSpanInScope(span)) { return response = protocolExec.execute(route, request, clientContext, execAware); } catch (IOException | HttpException | RuntimeException | Error e) { error = e; throw e; } finally { handler.handleReceive(response, error, span); } } }
@Override public void process(HttpRequest request, HttpContext context) { HttpHost host = HttpClientContext.adapt(context).getTargetHost(); TraceContext parent = (TraceContext) context.getAttribute(TraceContext.class.getName()); Span span; try (Scope scope = currentTraceContext.maybeScope(parent)) { span = handler.nextSpan(request); } HttpRequestWrapper requestWrapper = HttpRequestWrapper.wrap(request, host); parseTargetAddress(requestWrapper, span); handler.handleSend(injector, request, requestWrapper, span); context.setAttribute(Span.class.getName(), span); context.setAttribute(Scope.class.getName(), currentTraceContext.newScope(span.context())); } }