Class OkHttpTelemetryBuilder
java.lang.Object
io.opentelemetry.instrumentation.okhttp.v3_0.OkHttpTelemetryBuilder
A builder of
OkHttpTelemetry.-
Method Summary
Modifier and TypeMethodDescriptionaddAttributesExtractor(io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor<okhttp3.Request, okhttp3.Response> attributesExtractor) Adds an additionalAttributesExtractorto invoke to set attributes to instrumented items.build()Returns a newOkHttpTelemetrywith the settings of thisOkHttpTelemetryBuilder.setCapturedRequestHeaders(List<String> requestHeaders) Configures the HTTP request headers that will be captured as span attributes.setCapturedResponseHeaders(List<String> responseHeaders) Configures the HTTP response headers that will be captured as span attributes.setEmitExperimentalHttpClientMetrics(boolean emitExperimentalHttpClientMetrics) Configures the instrumentation to emit experimental HTTP client metrics.setKnownMethods(Set<String> knownMethods) Configures the instrumentation to recognize an alternative set of HTTP request methods.
-
Method Details
-
addAttributesExtractor
@CanIgnoreReturnValue public OkHttpTelemetryBuilder addAttributesExtractor(io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor<okhttp3.Request, okhttp3.Response> attributesExtractor) Adds an additionalAttributesExtractorto invoke to set attributes to instrumented items. -
setCapturedRequestHeaders
@CanIgnoreReturnValue public OkHttpTelemetryBuilder setCapturedRequestHeaders(List<String> requestHeaders) Configures the HTTP request headers that will be captured as span attributes.- Parameters:
requestHeaders- A list of HTTP header names.
-
setCapturedResponseHeaders
@CanIgnoreReturnValue public OkHttpTelemetryBuilder setCapturedResponseHeaders(List<String> responseHeaders) Configures the HTTP response headers that will be captured as span attributes.- Parameters:
responseHeaders- A list of HTTP header names.
-
setKnownMethods
Configures the instrumentation to recognize an alternative set of HTTP request methods.By default, this instrumentation defines "known" methods as the ones listed in RFC9110 and the PATCH method defined in RFC5789.
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.- See Also:
-
HttpClientAttributesExtractorBuilder.setKnownMethods(Set)
-
setEmitExperimentalHttpClientMetrics
@CanIgnoreReturnValue public OkHttpTelemetryBuilder setEmitExperimentalHttpClientMetrics(boolean emitExperimentalHttpClientMetrics) Configures the instrumentation to emit experimental HTTP client metrics.- Parameters:
emitExperimentalHttpClientMetrics-trueif the experimental HTTP client metrics are to be emitted.
-
build
Returns a newOkHttpTelemetrywith the settings of thisOkHttpTelemetryBuilder.
-