Class HttpRouteHolder
- java.lang.Object
-
- io.opentelemetry.instrumentation.api.instrumenter.http.HttpRouteHolder
-
public final class HttpRouteHolder extends Object
A helper class that keeps track of thehttp.routeattribute 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 Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <REQUEST> ContextCustomizer<REQUEST>get()Returns aContextCustomizerthat initializes aHttpRouteHolderin theContextreturned fromInstrumenter.start(Context, Object).static <T,U>
voidupdateHttpRoute(io.opentelemetry.context.Context context, HttpRouteSource source, HttpRouteBiGetter<T,U> httpRouteGetter, T arg1, U arg2)Updates thehttp.routeattribute in the receivedcontext.static <T> voidupdateHttpRoute(io.opentelemetry.context.Context context, HttpRouteSource source, HttpRouteGetter<T> httpRouteGetter, T arg1)Updates thehttp.routeattribute in the receivedcontext.static voidupdateHttpRoute(io.opentelemetry.context.Context context, HttpRouteSource source, String httpRoute)Updates thehttp.routeattribute in the receivedcontext.
-
-
-
Method Detail
-
get
public static <REQUEST> ContextCustomizer<REQUEST> get()
Returns aContextCustomizerthat initializes aHttpRouteHolderin theContextreturned fromInstrumenter.start(Context, Object).
-
updateHttpRoute
public static void updateHttpRoute(io.opentelemetry.context.Context context, HttpRouteSource source, @Nullable String httpRoute)Updates thehttp.routeattribute in the receivedcontext.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 providedhttpRouteif and only if the lastHttpRouteSourceto update the route using this method has strictly lower priority than the providedHttpRouteSource, 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 thehttp.routeattribute in the receivedcontext.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 providedHttpRouteGetterif and only if the lastHttpRouteSourceto update the route using this method has strictly lower priority than the providedHttpRouteSource, and the value returned from theHttpRouteGetteris 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 providedHttpRouteGetterif 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 thehttp.routeattribute in the receivedcontext.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 providedHttpRouteBiGetterif and only if the lastHttpRouteSourceto update the route using this method has strictly lower priority than the providedHttpRouteSource, and the value returned from theHttpRouteBiGetteris 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 providedHttpRouteBiGetterif the value returned from it is non-null.
-
-