Class HttpServerRoute
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.
- Since:
- 2.0.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic <REQUEST> HttpServerRouteBuilder<REQUEST> builder(HttpServerAttributesGetter<REQUEST, ?> getter) Returns a newHttpServerRouteBuilderthat can be used to configure theHttpServerRoute.static <REQUEST> ContextCustomizer<REQUEST> create(HttpServerAttributesGetter<REQUEST, ?> getter) Returns aContextCustomizerthat initializes anHttpServerRoutein theContextreturned fromInstrumenter.start(Context, Object).static <T,U> void update(io.opentelemetry.context.Context context, HttpServerRouteSource source, HttpServerRouteBiGetter<T, U> httpRouteGetter, T arg1, U arg2) Updates thehttp.routeattribute in the receivedcontext.static <T> voidupdate(io.opentelemetry.context.Context context, HttpServerRouteSource source, HttpServerRouteGetter<T> httpRouteGetter, T arg1) Updates thehttp.routeattribute in the receivedcontext.static voidupdate(io.opentelemetry.context.Context context, HttpServerRouteSource source, String httpRoute) Updates thehttp.routeattribute in the receivedcontext.
-
Method Details
-
create
public static <REQUEST> ContextCustomizer<REQUEST> create(HttpServerAttributesGetter<REQUEST, ?> getter) Returns aContextCustomizerthat initializes anHttpServerRoutein theContextreturned fromInstrumenter.start(Context, Object).- See Also:
-
builder
public static <REQUEST> HttpServerRouteBuilder<REQUEST> builder(HttpServerAttributesGetter<REQUEST, ?> getter) Returns a newHttpServerRouteBuilderthat can be used to configure theHttpServerRoute. -
update
public static void update(io.opentelemetry.context.Context context, HttpServerRouteSource 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
HttpServerRoute, then this method will update the route using the providedhttpRouteif and only if the lastHttpServerRouteSourceto update the route using this method has strictly lower priority than the providedHttpServerRouteSource, and the passed value is non-null. -
update
public static <T> void update(io.opentelemetry.context.Context context, HttpServerRouteSource source, HttpServerRouteGetter<T> httpRouteGetter, @Nullable 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
HttpServerRoute, then this method will update the route using the providedHttpServerRouteGetterif and only if the lastHttpServerRouteSourceto update the route using this method has strictly lower priority than the providedHttpServerRouteSource, and the value returned from theHttpServerRouteGetteris non-null. -
update
public static <T,U> void update(io.opentelemetry.context.Context context, HttpServerRouteSource source, HttpServerRouteBiGetter<T, U> httpRouteGetter, @Nullable 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
HttpServerRoute, then this method will update the route using the providedHttpServerRouteBiGetterif and only if the lastHttpServerRouteSourceto update the route using this method has strictly lower priority than the providedHttpServerRouteSource, and the value returned from theHttpServerRouteBiGetteris non-null.
-