Class HttpServerAttributesExtractor<REQUEST,RESPONSE>

java.lang.Object
io.opentelemetry.instrumentation.api.instrumenter.http.HttpServerAttributesExtractor<REQUEST,RESPONSE>
All Implemented Interfaces:
io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor<REQUEST,RESPONSE>, io.opentelemetry.instrumentation.api.internal.SpanKeyProvider

public final class HttpServerAttributesExtractor<REQUEST,RESPONSE> extends Object implements io.opentelemetry.instrumentation.api.internal.SpanKeyProvider
Extractor of HTTP server attributes. Instrumentation of HTTP server frameworks should extend this class, defining HttpServerAttributesExtractor and HttpServerAttributesExtractor with the actual request / response types of the instrumented library. If an attribute is not available in this library, it is appropriate to return null from the protected attribute methods, but implement as many as possible for best compliance with the OpenTelemetry specification.
  • Method Details

    • create

      public static <REQUEST, RESPONSE> io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor<REQUEST,RESPONSE> create(HttpServerAttributesGetter<REQUEST,RESPONSE> httpAttributesGetter)
      Creates the HTTP server attributes extractor with default configuration.
    • create

      @Deprecated public static <REQUEST, RESPONSE> io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor<REQUEST,RESPONSE> create(HttpServerAttributesGetter<REQUEST,RESPONSE> httpAttributesGetter, NetServerAttributesGetter<REQUEST,RESPONSE> netAttributesGetter)
      Deprecated.
      Make sure that your getter implements all the network-related methods and use create(HttpServerAttributesGetter) instead. This method will be removed in the 2.0 release.
      Creates the HTTP server attributes extractor with default configuration.
    • builder

      public static <REQUEST, RESPONSE> HttpServerAttributesExtractorBuilder<REQUEST,RESPONSE> builder(HttpServerAttributesGetter<REQUEST,RESPONSE> httpAttributesGetter)
      Returns a new HttpServerAttributesExtractorBuilder that can be used to configure the HTTP client attributes extractor.
    • builder

      @Deprecated public static <REQUEST, RESPONSE> HttpServerAttributesExtractorBuilder<REQUEST,RESPONSE> builder(HttpServerAttributesGetter<REQUEST,RESPONSE> httpAttributesGetter, NetServerAttributesGetter<REQUEST,RESPONSE> netAttributesGetter)
      Deprecated.
      Make sure that your getter implements all the network-related methods and use builder(HttpServerAttributesGetter) instead. This method will be removed in the 2.0 release.
      Returns a new HttpServerAttributesExtractorBuilder that can be used to configure the HTTP client attributes extractor.
    • onStart

      public void onStart(io.opentelemetry.api.common.AttributesBuilder attributes, io.opentelemetry.context.Context parentContext, REQUEST request)
      Specified by:
      onStart in interface io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor<REQUEST,RESPONSE>
    • onEnd

      public void onEnd(io.opentelemetry.api.common.AttributesBuilder attributes, io.opentelemetry.context.Context context, REQUEST request, @Nullable RESPONSE response, @Nullable Throwable error)
      Specified by:
      onEnd in interface io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor<REQUEST,RESPONSE>
    • internalGetSpanKey

      public io.opentelemetry.instrumentation.api.internal.SpanKey internalGetSpanKey()
      This method is internal and is hence not for public use. Its API is unstable and can change at any time.
      Specified by:
      internalGetSpanKey in interface io.opentelemetry.instrumentation.api.internal.SpanKeyProvider