Class HttpAttributesExtractor<REQUEST,RESPONSE>
- java.lang.Object
-
- io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor<REQUEST,RESPONSE>
-
- io.opentelemetry.instrumentation.api.instrumenter.http.HttpAttributesExtractor<REQUEST,RESPONSE>
-
public abstract class HttpAttributesExtractor<REQUEST,RESPONSE> extends AttributesExtractor<REQUEST,RESPONSE>
Extractor of HTTP attributes. Instrumentation of HTTP server or client frameworks should extend this class, definingHttpAttributesExtractorandHttpAttributesExtractorwith the actual request / response types of the instrumented library. If an attribute is not available in this library, it is appropriate to returnnullfrom the protected attribute methods, but implement as many as possible for best compliance with the OpenTelemetry specification.
-
-
Constructor Summary
Constructors Constructor Description HttpAttributesExtractor()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract @Nullable StringclientIp(REQUEST request, @Nullable RESPONSE response)Extracts thehttp.client_ipspan attribute.protected abstract @Nullable Stringflavor(REQUEST request, @Nullable RESPONSE response)Extracts thehttp.flavorspan attribute.protected abstract @Nullable Stringhost(REQUEST request)protected abstract @Nullable Stringmethod(REQUEST request)protected voidonEnd(io.opentelemetry.api.common.AttributesBuilder attributes, REQUEST request, @Nullable RESPONSE response)Extracts attributes from theAttributesExtractorandAttributesExtractorinto theAttributesBuilderat the end of a request.protected voidonStart(io.opentelemetry.api.common.AttributesBuilder attributes, REQUEST request)Extracts attributes from theAttributesExtractorinto theAttributesBuilderat the beginning of a request.protected abstract @Nullable LongrequestContentLength(REQUEST request, @Nullable RESPONSE response)Extracts thehttp.request_content_lengthspan attribute.protected abstract @Nullable LongrequestContentLengthUncompressed(REQUEST request, @Nullable RESPONSE response)Extracts thehttp.request_content_length_uncompressedspan attribute.protected abstract @Nullable LongresponseContentLength(REQUEST request, RESPONSE response)Extracts thehttp.response_content_lengthspan attribute.protected abstract @Nullable LongresponseContentLengthUncompressed(REQUEST request, RESPONSE response)Extracts thehttp.response_content_length_uncompressedspan attribute.protected abstract @Nullable Stringroute(REQUEST request)protected abstract @Nullable Stringscheme(REQUEST request)protected abstract @Nullable StringserverName(REQUEST request, @Nullable RESPONSE response)Extracts thehttp.server_namespan attribute.protected abstract @Nullable IntegerstatusCode(REQUEST request, RESPONSE response)Extracts thehttp.status_codespan attribute.protected abstract @Nullable Stringtarget(REQUEST request)protected abstract @Nullable Stringurl(REQUEST request)protected abstract @Nullable StringuserAgent(REQUEST request)-
Methods inherited from class io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor
set
-
-
-
-
Method Detail
-
onStart
protected final void onStart(io.opentelemetry.api.common.AttributesBuilder attributes, REQUEST request)Description copied from class:AttributesExtractorExtracts attributes from theAttributesExtractorinto theAttributesBuilderat the beginning of a request.- Specified by:
onStartin classAttributesExtractor<REQUEST,RESPONSE>
-
onEnd
protected final void onEnd(io.opentelemetry.api.common.AttributesBuilder attributes, REQUEST request, @Nullable RESPONSE response)Description copied from class:AttributesExtractorExtracts attributes from theAttributesExtractorandAttributesExtractorinto theAttributesBuilderat the end of a request.- Specified by:
onEndin classAttributesExtractor<REQUEST,RESPONSE>
-
requestContentLength
protected abstract @Nullable Long requestContentLength(REQUEST request, @Nullable RESPONSE response)
Extracts thehttp.request_content_lengthspan attribute.This is called from
Instrumenter.end(Context, Object, Object, Throwable), whetherresponseisnullor not.
-
requestContentLengthUncompressed
protected abstract @Nullable Long requestContentLengthUncompressed(REQUEST request, @Nullable RESPONSE response)
Extracts thehttp.request_content_length_uncompressedspan attribute.This is called from
Instrumenter.end(Context, Object, Object, Throwable), whetherresponseisnullor not.
-
flavor
protected abstract @Nullable String flavor(REQUEST request, @Nullable RESPONSE response)
Extracts thehttp.flavorspan attribute.This is called from
Instrumenter.end(Context, Object, Object, Throwable), whetherresponseisnullor not.
-
serverName
protected abstract @Nullable String serverName(REQUEST request, @Nullable RESPONSE response)
Extracts thehttp.server_namespan attribute.This is called from
Instrumenter.end(Context, Object, Object, Throwable), whetherresponseisnullor not.
-
clientIp
protected abstract @Nullable String clientIp(REQUEST request, @Nullable RESPONSE response)
Extracts thehttp.client_ipspan attribute.This is called from
Instrumenter.end(Context, Object, Object, Throwable), whetherresponseisnullor not.
-
statusCode
protected abstract @Nullable Integer statusCode(REQUEST request, RESPONSE response)
Extracts thehttp.status_codespan attribute.This is called from
Instrumenter.end(Context, Object, Object, Throwable), only whenresponseis non-null.
-
responseContentLength
protected abstract @Nullable Long responseContentLength(REQUEST request, RESPONSE response)
Extracts thehttp.response_content_lengthspan attribute.This is called from
Instrumenter.end(Context, Object, Object, Throwable), only whenresponseis non-null.
-
responseContentLengthUncompressed
protected abstract @Nullable Long responseContentLengthUncompressed(REQUEST request, RESPONSE response)
Extracts thehttp.response_content_length_uncompressedspan attribute.This is called from
Instrumenter.end(Context, Object, Object, Throwable), only whenresponseis non-null.
-
-