Class OkHttpTracing


  • public final class OkHttpTracing
    extends Object
    Entrypoint for tracing OkHttp clients.
    • Method Detail

      • create

        public static OkHttpTracing create​(io.opentelemetry.api.OpenTelemetry openTelemetry)
        Returns a new OkHttpTracing 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.