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

public final class HttpRouteHolder 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

    • get

      public static <REQUEST> io.opentelemetry.instrumentation.api.instrumenter.ContextCustomizer<REQUEST> get()
      Returns a ContextCustomizer that initializes a HttpRouteHolder in the Context returned from Instrumenter.start(Context, Object).
    • updateHttpRoute

      public static void updateHttpRoute(io.opentelemetry.context.Context context, HttpRouteSource 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 HttpRouteHolder, then this method will update the route using the provided httpRoute if and only if the last HttpRouteSource to update the route using this method has strictly lower priority than the provided HttpRouteSource, 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 HttpRouteHolder, then this method will update the route using the provided value if it is non-null.

    • updateHttpRoute

      public static <T> void updateHttpRoute(io.opentelemetry.context.Context context, HttpRouteSource source, HttpRouteGetter<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 HttpRouteHolder, then this method will update the route using the provided HttpRouteGetter if and only if the last HttpRouteSource to update the route using this method has strictly lower priority than the provided HttpRouteSource, and the value returned from the HttpRouteGetter is non-null.

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

    • updateHttpRoute

      public static <T, U> void updateHttpRoute(io.opentelemetry.context.Context context, HttpRouteSource source, HttpRouteBiGetter<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 HttpRouteHolder, then this method will update the route using the provided HttpRouteBiGetter if and only if the last HttpRouteSource to update the route using this method has strictly lower priority than the provided HttpRouteSource, and the value returned from the HttpRouteBiGetter 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 HttpRouteBiGetter if the value returned from it is non-null.