Class OkHttpTelemetryBuilder

java.lang.Object
io.opentelemetry.instrumentation.okhttp.v3_0.OkHttpTelemetryBuilder

public final class OkHttpTelemetryBuilder extends Object
A builder of OkHttpTelemetry.
  • Method Details

    • addAttributesExtractor

      @CanIgnoreReturnValue public OkHttpTelemetryBuilder addAttributesExtractor(io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor<okhttp3.Request,okhttp3.Response> attributesExtractor)
      Adds an additional AttributesExtractor to 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

      @CanIgnoreReturnValue public OkHttpTelemetryBuilder setKnownMethods(Set<String> knownMethods)
      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 - true if the experimental HTTP client metrics are to be emitted.
    • build

      public OkHttpTelemetry build()
      Returns a new OkHttpTelemetry with the settings of this OkHttpTelemetryBuilder.