Q - the HTTP request entity.P - the HTTP response entity.C - the type of the carrier.@ExperimentalApi public class HttpClientHandler<Q,P,C> extends Object
| Constructor and Description |
|---|
HttpClientHandler(io.opencensus.trace.Tracer tracer,
HttpExtractor<Q,P> extractor,
io.opencensus.trace.propagation.TextFormat textFormat,
io.opencensus.trace.propagation.TextFormat.Setter<C> setter)
Creates a
HttpClientHandler with given parameters. |
| Modifier and Type | Method and Description |
|---|---|
io.opencensus.trace.Span |
getSpanFromContext(HttpRequestContext context)
Retrieves
Span from the HttpRequestContext. |
void |
handleEnd(HttpRequestContext context,
Q request,
P response,
Throwable error)
Close an HTTP span and records stats specific to the request.
|
void |
handleMessageReceived(HttpRequestContext context,
long bytes)
Instrument an HTTP span after a message is received.
|
void |
handleMessageSent(HttpRequestContext context,
long bytes)
Instrument an HTTP span after a message is sent.
|
HttpRequestContext |
handleStart(io.opencensus.trace.Span parent,
C carrier,
Q request)
Instrument a request for tracing and stats before it is sent.
|
public HttpClientHandler(io.opencensus.trace.Tracer tracer,
HttpExtractor<Q,P> extractor,
io.opencensus.trace.propagation.TextFormat textFormat,
io.opencensus.trace.propagation.TextFormat.Setter<C> setter)
HttpClientHandler with given parameters.tracer - the Open Census tracing component.extractor - the HttpExtractor used to extract information from the
request/response.textFormat - the TextFormat used in HTTP propagation.setter - the setter used when injecting information to the carrier.public HttpRequestContext handleStart(@Nullable io.opencensus.trace.Span parent, C carrier, Q request)
This method will create a span in current context to represent the HTTP call. The created span will be serialized and propagated to the server.
The generated span will NOT be set as current context. User can control when to enter the
scope of this span. Use AbstractHttpHandler.getSpanFromContext(io.opencensus.contrib.http.HttpRequestContext) to retrieve the span.
parent - the parent Span. null indicates using current span.carrier - the entity that holds the HTTP information.request - the request entity.HttpRequestContext that contains stats and trace data associated with the
request.public void handleEnd(HttpRequestContext context, @Nullable Q request, @Nullable P response, @Nullable Throwable error)
This method will set status of the span and end it. Additionally it will record measurements associated with the request.
context - the HttpRequestContext returned from handleStart(Span, Object, Object)request - the HTTP request entity.response - the HTTP response entity. null means invalid response.error - the error occurs when processing the response.public final void handleMessageSent(HttpRequestContext context, long bytes)
context - request specific HttpRequestContextbytes - bytes sent.public final void handleMessageReceived(HttpRequestContext context, long bytes)
context - request specific HttpRequestContextbytes - bytes received.public io.opencensus.trace.Span getSpanFromContext(HttpRequestContext context)
Span from the HttpRequestContext.context - request specific HttpRequestContextSpan associated with the request.