Interface AttributesExtractor<REQUEST,RESPONSE>


public interface AttributesExtractor<REQUEST,RESPONSE>
Extractor of Attributes for a given request and response. Will be called on start with just the AttributesExtractor and again on end with both AttributesExtractor and AttributesExtractor to allow populating attributes at each stage of a request's lifecycle. It is best to populate as much as possible in onStart(AttributesBuilder, Context, Object) to have it available during sampling.
  • Method Summary

    Modifier and Type
    Method
    Description
    static <REQUEST, RESPONSE, T>
    AttributesExtractor<REQUEST,RESPONSE>
    constant(io.opentelemetry.api.common.AttributeKey<T> attributeKey, T attributeValue)
    Returns an AttributesExtractor implementation that always extracts the provided constant value.
    void
    onEnd(io.opentelemetry.api.common.AttributesBuilder attributes, io.opentelemetry.context.Context context, REQUEST request, RESPONSE response, Throwable error)
    Extracts attributes from the Context, the AttributesExtractor and either AttributesExtractor or error into the AttributesBuilder at the end of a request.
    void
    onStart(io.opentelemetry.api.common.AttributesBuilder attributes, io.opentelemetry.context.Context parentContext, REQUEST request)
    Extracts attributes from the Context and the AttributesExtractor into the AttributesBuilder at the beginning of a request.
    default <T> void
    set(io.opentelemetry.api.common.AttributesBuilder attributes, io.opentelemetry.api.common.AttributeKey<T> key, T value)
    Deprecated.
    This method will be removed.
  • Method Details

    • onStart

      void onStart(io.opentelemetry.api.common.AttributesBuilder attributes, io.opentelemetry.context.Context parentContext, REQUEST request)
      Extracts attributes from the Context and the AttributesExtractor into the AttributesBuilder at the beginning of a request.
    • onEnd

      void onEnd(io.opentelemetry.api.common.AttributesBuilder attributes, io.opentelemetry.context.Context context, REQUEST request, @Nullable RESPONSE response, @Nullable Throwable error)
      Extracts attributes from the Context, the AttributesExtractor and either AttributesExtractor or error into the AttributesBuilder at the end of a request.
    • set

      @Deprecated default <T> void set(io.opentelemetry.api.common.AttributesBuilder attributes, io.opentelemetry.api.common.AttributeKey<T> key, @Nullable T value)
      Deprecated.
      This method will be removed.
      Sets the value with the given key to the AttributesBuilder if value is not null.
    • constant

      static <REQUEST, RESPONSE, T> AttributesExtractor<REQUEST,RESPONSE> constant(io.opentelemetry.api.common.AttributeKey<T> attributeKey, T attributeValue)
      Returns an AttributesExtractor implementation that always extracts the provided constant value.