Q - the HTTP request entity.P - the HTTP response entity.C - the type of the carrier.@ExperimentalApi public class HttpServerHandler<Q,P,C> extends Object
| Constructor and Description |
|---|
HttpServerHandler(io.opencensus.trace.Tracer tracer,
HttpExtractor<Q,P> extractor,
io.opencensus.trace.propagation.TextFormat textFormat,
io.opencensus.trace.propagation.TextFormat.Getter<C> getter,
Boolean publicEndpoint)
Creates a
HttpServerHandler 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(C carrier,
Q request)
Instrument an incoming request before it is handled.
|
public HttpServerHandler(io.opencensus.trace.Tracer tracer,
HttpExtractor<Q,P> extractor,
io.opencensus.trace.propagation.TextFormat textFormat,
io.opencensus.trace.propagation.TextFormat.Getter<C> getter,
Boolean publicEndpoint)
HttpServerHandler 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.getter - the getter used when extracting information from the carrier.publicEndpoint - set to true for publicly accessible HTTP(S) server. If true then incoming
tracecontext will be added as a link instead of as a parent.public HttpRequestContext handleStart(C carrier, Q request)
This method will create a span under the deserialized propagated parent context. If the parent context is not present, the span will be created under the current context.
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.
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, Q request, @Nullable P response, @Nullable Throwable error)
This method will set status of the span and end it. Additionally it will record message events for the span and record measurements associated with the request.
context - the HttpRequestContext used with handleStart(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.