Req
- the native http request type of the server.Resp
- the native http response type of the server.public final class HttpServerHandler<Req,Resp>
extends java.lang.Object
HttpServerParser
.
This is an example of synchronous instrumentation:
Span span = handler.handleReceive(extractor, request);
Throwable error = null;
try (Tracer.SpanInScope ws = tracer.withSpanInScope(span)) {
// any downstream code can see Tracer.currentSpan() or use Tracer.currentSpanCustomizer()
response = invoke(request);
} catch (RuntimeException | Error e) {
error = e;
throw e;
} finally {
handler.handleSend(response, error, span);
}
Modifier and Type | Method | Description |
---|---|---|
static <Req,Resp> HttpServerHandler<Req,Resp> |
create(HttpTracing httpTracing,
HttpServerAdapter<Req,Resp> adapter) |
|
<C> Span |
handleReceive(TraceContext.Extractor<C> extractor,
C carrier,
Req request) |
Like
handleReceive(TraceContext.Extractor, Object) , except for when the carrier of
trace data is not the same as the request. |
Span |
handleReceive(TraceContext.Extractor<Req> extractor,
Req request) |
Conditionally joins a span, or starts a new trace, depending on if a trace context was
extracted from the request.
|
void |
handleSend(Resp response,
java.lang.Throwable error,
Span span) |
Finishes the server span after assigning it tags according to the response or error.
|
public static <Req,Resp> HttpServerHandler<Req,Resp> create(HttpTracing httpTracing, HttpServerAdapter<Req,Resp> adapter)
public Span handleReceive(TraceContext.Extractor<Req> extractor, Req request)
This is typically called before the request is processed by the actual library.
public <C> Span handleReceive(TraceContext.Extractor<C> extractor, C carrier, Req request)
handleReceive(TraceContext.Extractor, Object)
, except for when the carrier of
trace data is not the same as the request.
Request data is parsed before the span is started.
public void handleSend(@Nullable Resp response, @Nullable java.lang.Throwable error, Span span)
This is typically called once the response headers are sent, and after the span is no longer in scope
.
Copyright © 2018 OpenZipkin. All rights reserved.