java.lang.Object
io.opentelemetry.instrumentation.api.instrumenter.http.HttpServerRoute

public final class HttpServerRoute extends Object
A helper class that keeps track of the http.route attribute value during HTTP server request processing.

Usually the route is not accessible when the request processing starts; and needs to be set later, after the instrumented operation starts. This class provides several static methods that allow the instrumentation author to provide the matching HTTP route to the instrumentation when it is discovered.

  • Method Details

    • create

      public static <REQUEST> io.opentelemetry.instrumentation.api.instrumenter.ContextCustomizer<REQUEST> create(HttpServerAttributesGetter<REQUEST,?> getter)
      Returns a ContextCustomizer that initializes an HttpServerRoute in the Context returned from Instrumenter.start(Context, Object).
    • builder

      public static <REQUEST> HttpServerRouteBuilder<REQUEST> builder(HttpServerAttributesGetter<REQUEST,?> getter)
      Returns a new HttpServerRouteBuilder that can be used to configure the HttpServerRoute.
    • update

      public static void update(io.opentelemetry.context.Context context, HttpServerRouteSource source, @Nullable String httpRoute)
      Updates the http.route attribute in the received context.

      If there is a server span in the context, and the context has been customized with a HttpServerRoute, then this method will update the route using the provided httpRoute if and only if the last HttpServerRouteSource to update the route using this method has strictly lower priority than the provided HttpServerRouteSource, and the passed value is non-null.

      If there is a server span in the context, and the context has NOT been customized with a HttpServerRoute, then this method will update the route using the provided value if it is non-null.

    • update

      public static <T> void update(io.opentelemetry.context.Context context, HttpServerRouteSource source, HttpServerRouteGetter<T> httpRouteGetter, T arg1)
      Updates the http.route attribute in the received context.

      If there is a server span in the context, and the context has been customized with a HttpServerRoute, then this method will update the route using the provided HttpServerRouteGetter if and only if the last HttpServerRouteSource to update the route using this method has strictly lower priority than the provided HttpServerRouteSource, and the value returned from the HttpServerRouteGetter is non-null.

      If there is a server span in the context, and the context has NOT been customized with a HttpServerRoute, then this method will update the route using the provided HttpServerRouteGetter if the value returned from it is non-null.

    • update

      public static <T, U> void update(io.opentelemetry.context.Context context, HttpServerRouteSource source, HttpServerRouteBiGetter<T,U> httpRouteGetter, T arg1, U arg2)
      Updates the http.route attribute in the received context.

      If there is a server span in the context, and the context has been customized with a HttpServerRoute, then this method will update the route using the provided HttpServerRouteBiGetter if and only if the last HttpServerRouteSource to update the route using this method has strictly lower priority than the provided HttpServerRouteSource, and the value returned from the HttpServerRouteBiGetter is non-null.

      If there is a server span in the context, and the context has NOT been customized with a ServerSpanName, then this method will update the route using the provided HttpServerRouteBiGetter if the value returned from it is non-null.