Req - the native http request type of the client.Resp - the native http response type of the client.public final class HttpClientHandler<Req,Resp>
extends java.lang.Object
HttpClientParser.
This is an example of synchronous instrumentation:
Span span = handler.handleSend(injector, request);
Throwable error = null;
try (Tracer.SpanInScope ws = tracer.withSpanInScope(span)) {
response = invoke(request); // any downstream code can see Tracer.currentSpan
} catch (RuntimeException | Error e) {
error = e;
throw e;
} finally {
handler.handleReceive(response, error, span);
}
| Modifier and Type | Method | Description |
|---|---|---|
static <Req,Resp> HttpClientHandler |
create(HttpTracing httpTracing,
HttpClientAdapter<Req,Resp> adapter) |
|
void |
handleReceive(Resp response,
java.lang.Throwable error,
Span span) |
Finishes the client span after assigning it tags according to the response or error.
|
<C> Span |
handleSend(TraceContext.Injector<C> injector,
C carrier,
Req request) |
Like
handleSend(TraceContext.Injector, Object), except for when the carrier of
trace data is not the same as the request. |
<C> Span |
handleSend(TraceContext.Injector<C> injector,
C carrier,
Req request,
Span span) |
Like
handleSend(TraceContext.Injector, Object, Object), except explicitly controls the
span representing the request. |
Span |
handleSend(TraceContext.Injector<Req> injector,
Req request) |
Starts the client span after assigning it a name and tags.
|
Span |
handleSend(TraceContext.Injector<Req> injector,
Req request,
Span span) |
Like
handleSend(TraceContext.Injector, Object), except explicitly controls the span
representing the request. |
Span |
nextSpan(Req request) |
Creates a potentially noop span representing this request.
|
public static <Req,Resp> HttpClientHandler create(HttpTracing httpTracing, HttpClientAdapter<Req,Resp> adapter)
public Span handleSend(TraceContext.Injector<Req> injector, Req request)
injects the trace context onto the request
before returning.
Call this before sending the request on the wire.
public <C> Span handleSend(TraceContext.Injector<C> injector, C carrier, Req request)
handleSend(TraceContext.Injector, Object), except for when the carrier of
trace data is not the same as the request.public Span handleSend(TraceContext.Injector<Req> injector, Req request, Span span)
handleSend(TraceContext.Injector, Object), except explicitly controls the span
representing the request.public <C> Span handleSend(TraceContext.Injector<C> injector, C carrier, Req request, Span span)
handleSend(TraceContext.Injector, Object, Object), except explicitly controls the
span representing the request.public Span nextSpan(Req request)
public void handleReceive(@Nullable Resp response, @Nullable java.lang.Throwable error, Span span)
This is typically called once the response headers are received, and after the span is
no longer in scope.
Copyright © 2018 OpenZipkin. All rights reserved.