Package io.opencensus.contrib.http
Class AbstractHttpHandler<Q,P>
java.lang.Object
io.opencensus.contrib.http.AbstractHttpHandler<Q,P>
- Direct Known Subclasses:
HttpClientHandler
,HttpServerHandler
Base class for handling request on http client and server.
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) final HttpExtractor
<Q, P> TheHttpExtractor
used to extract information from request/response. -
Constructor Summary
ConstructorsConstructorDescriptionAbstractHttpHandler
(HttpExtractor<Q, P> extractor) Constructor to allow access from same package subclasses only. -
Method Summary
Modifier and TypeMethodDescription(package private) final void
addSpanRequestAttributes
(Span span, Q request, HttpExtractor<Q, P> extractor) (package private) HttpRequestContext
getNewContext
(Span span, TagContext tagContext) getSpanFromContext
(HttpRequestContext context) RetrievesSpan
from theHttpRequestContext
.(package private) final String
getSpanName
(Q request, HttpExtractor<Q, P> extractor) final void
handleMessageReceived
(HttpRequestContext context, long bytes) Instrument an HTTP span after a message is received.final void
handleMessageSent
(HttpRequestContext context, long bytes) Instrument an HTTP span after a message is sent.private static void
putAttributeIfNotEmptyOrNull
(Span span, String key, String value) (package private) static void
recordMessageEvent
(Span span, long id, MessageEvent.Type type, long uncompressedMessageSize, long compressedMessageSize) A convenience to record aMessageEvent
with given parameters.(package private) void
-
Field Details
-
extractor
TheHttpExtractor
used to extract information from request/response.
-
-
Constructor Details
-
AbstractHttpHandler
AbstractHttpHandler(HttpExtractor<Q, P> extractor) Constructor to allow access from same package subclasses only.
-
-
Method Details
-
recordMessageEvent
static void recordMessageEvent(Span span, long id, MessageEvent.Type type, long uncompressedMessageSize, long compressedMessageSize) A convenience to record aMessageEvent
with given parameters.- Parameters:
span
- the span which thisMessageEvent
will be added to.id
- the id of the event.type
- theMessageEvent.Type
of the event.uncompressedMessageSize
- size of the message before compressed (optional).compressedMessageSize
- size of the message after compressed (optional).- Since:
- 0.19
-
putAttributeIfNotEmptyOrNull
-
handleMessageSent
Instrument an HTTP span after a message is sent. Typically called for every chunk of request or response is sent.- Parameters:
context
- request specificHttpRequestContext
bytes
- bytes sent.- Since:
- 0.19
-
handleMessageReceived
Instrument an HTTP span after a message is received. Typically called for every chunk of request or response is received.- Parameters:
context
- request specificHttpRequestContext
bytes
- bytes received.- Since:
- 0.19
-
spanEnd
-
getSpanName
-
addSpanRequestAttributes
-
getSpanFromContext
RetrievesSpan
from theHttpRequestContext
.- Parameters:
context
- request specificHttpRequestContext
- Returns:
Span
associated with the request.- Since:
- 0.19
-
getNewContext
-