Class OkHttpInstrumentation

  • All Implemented Interfaces:
    io.opentelemetry.android.instrumentation.AndroidInstrumentation

    @AutoService(value = {AndroidInstrumentation.class}) 
    public final class OkHttpInstrumentation
     implements AndroidInstrumentation
                        

    Instrumentation for okhttp requests.

    • Constructor Detail

      • OkHttpInstrumentation

        OkHttpInstrumentation()
    • 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_original attribute.

        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_original attribute.

        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.