Class OkHttpInstrumentation
-
- All Implemented Interfaces:
-
io.opentelemetry.android.instrumentation.AndroidInstrumentation
@AutoService(value = {AndroidInstrumentation.class}) public final class OkHttpInstrumentation implements AndroidInstrumentationInstrumentation for okhttp requests.
-
-
Field Summary
Fields Modifier and Type Field Description public final List<AttributesExtractor<Interceptor.Chain, Response>>additionalExtractorsprivate List<String>capturedRequestHeadersprivate List<String>capturedResponseHeadersprivate Set<String>knownMethodsprivate final Stringname
-
Constructor Summary
Constructors Constructor Description OkHttpInstrumentation()
-
Method Summary
Modifier and Type Method Description final List<String>getCapturedRequestHeaders()Configures the HTTP request headers that will be captured as span attributes as described in HTTP semantic conventions. final UnitsetCapturedRequestHeaders(List<String> capturedRequestHeaders)Configures the HTTP request headers that will be captured as span attributes as described in HTTP semantic conventions. final List<String>getCapturedResponseHeaders()Configures the HTTP response headers that will be captured as span attributes as described in HTTP semantic conventions. final UnitsetCapturedResponseHeaders(List<String> capturedResponseHeaders)Configures the HTTP response headers that will be captured as span attributes as described in HTTP semantic conventions. final Set<String>getKnownMethods()Configures the attrs extractor to recognize an alternative set of HTTP request methods. final UnitsetKnownMethods(Set<String> knownMethods)Configures the attrs extractor to recognize an alternative set of HTTP request methods. StringgetName()final UnitaddAttributesExtractor(AttributesExtractor<Interceptor.Chain, Response> extractor)Adds an AttributesExtractor that will extract additional attributes. final UnitsetPeerServiceMapping(Map<String, String> peerServiceMapping)Configures the extractor of the peer.servicespan attribute, described in the specification.final UnitsetEmitExperimentalHttpClientTelemetry(Boolean emitExperimentalHttpClientTelemetry)When enabled keeps track of non-stable HTTP client metrics: the request size and the the response size. final BooleanemitExperimentalHttpClientTelemetry()Unitinstall(Context context, OpenTelemetryRum openTelemetryRum)-
-
Method Detail
-
getCapturedRequestHeaders
final List<String> getCapturedRequestHeaders()
Configures the HTTP request headers that will be captured as span attributes as described in HTTP semantic conventions.
The HTTP request header values will be captured under the
http.request.header.<name>attribute key. The<name>part in the attribute key is the normalized header name: lowercase, with dashes replaced by underscores.
-
setCapturedRequestHeaders
final Unit setCapturedRequestHeaders(List<String> capturedRequestHeaders)
Configures the HTTP request headers that will be captured as span attributes as described in HTTP semantic conventions.
The HTTP request header values will be captured under the
http.request.header.<name>attribute key. The<name>part in the attribute key is the normalized header name: lowercase, with dashes replaced by underscores.- Parameters:
capturedRequestHeaders- A list of HTTP header names.
-
getCapturedResponseHeaders
final List<String> getCapturedResponseHeaders()
Configures the HTTP response headers that will be captured as span attributes as described in HTTP semantic conventions.
The HTTP response header values will be captured under the
http.response.header.<name>attribute key. The<name>part in the attribute key is the normalized header name: lowercase, with dashes replaced by underscores.
-
setCapturedResponseHeaders
final Unit setCapturedResponseHeaders(List<String> capturedResponseHeaders)
Configures the HTTP response headers that will be captured as span attributes as described in HTTP semantic conventions.
The HTTP response header values will be captured under the
http.response.header.<name>attribute key. The<name>part in the attribute key is the normalized header name: lowercase, with dashes replaced by underscores.- Parameters:
capturedResponseHeaders- A list of HTTP header names.
-
getKnownMethods
final Set<String> getKnownMethods()
Configures the attrs extractor to recognize an alternative set of HTTP request methods.
By default, the extractor defines "known" methods as the ones listed in RFC9110 and the PATCH method defined in RFC5789. If an unknown method is encountered, the extractor will use the value {@value HttpConstants#_OTHER} instead of it and put the original value in an extra
http.request.method_originalattribute.Note: calling this method overrides the default known method sets completely; it does not supplement it.
-
setKnownMethods
final Unit setKnownMethods(Set<String> knownMethods)
Configures the attrs extractor to recognize an alternative set of HTTP request methods.
By default, the extractor defines "known" methods as the ones listed in RFC9110 and the PATCH method defined in RFC5789. If an unknown method is encountered, the extractor will use the value {@value HttpConstants#_OTHER} instead of it and put the original value in an extra
http.request.method_originalattribute.Note: calling this method overrides the default known method sets completely; it does not supplement it.
- Parameters:
knownMethods- A set of recognized HTTP request methods.
-
addAttributesExtractor
final Unit addAttributesExtractor(AttributesExtractor<Interceptor.Chain, Response> extractor)
Adds an AttributesExtractor that will extract additional attributes.
-
setPeerServiceMapping
final Unit setPeerServiceMapping(Map<String, String> peerServiceMapping)
Configures the extractor of the
peer.servicespan attribute, described in the specification.
-
setEmitExperimentalHttpClientTelemetry
final Unit setEmitExperimentalHttpClientTelemetry(Boolean emitExperimentalHttpClientTelemetry)
When enabled keeps track of non-stable HTTP client metrics: the request size and the the response size.
-
emitExperimentalHttpClientTelemetry
final Boolean emitExperimentalHttpClientTelemetry()
-
-
-
-