Class OkHttpTelemetry

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

public final class OkHttpTelemetry extends Object
Entrypoint for instrumenting OkHttp clients.
  • Method Details

    • create

      public static OkHttpTelemetry create(io.opentelemetry.api.OpenTelemetry openTelemetry)
      Returns a new OkHttpTelemetry configured with the given OpenTelemetry.
    • builder

      public static OkHttpTelemetryBuilder builder(io.opentelemetry.api.OpenTelemetry openTelemetry)
      Returns a new OkHttpTelemetryBuilder configured with the given OpenTelemetry.
    • newInterceptor

      @Deprecated public okhttp3.Interceptor newInterceptor()
      Deprecated.
      Please use the newCallFactory(OkHttpClient) method instead.
      Returns a new Interceptor that can be used with methods like OkHttpClient.Builder.addInterceptor(Interceptor).

      Important: asynchronous calls using Call.enqueue(Callback) will *not* work correctly using just this interceptor.

      It is strongly recommended that you use the newCallFactory(OkHttpClient) method to decorate your OkHttpClient, rather than using this method directly.

    • newCallFactory

      public okhttp3.Call.Factory newCallFactory(okhttp3.OkHttpClient baseClient)
      Construct a new OpenTelemetry tracing-enabled Call.Factory using the provided OkHttpClient instance.

      Using this method will result in proper propagation and span parenting, for both synchronous and asynchronous usages.

      Parameters:
      baseClient - An instance of OkHttpClient configured as desired.
      Returns:
      a Call.Factory for creating new Call instances.