Simplify some route getters (#9316)

This commit is contained in:
Trask Stalnaker 2023-08-28 00:24:30 -07:00 committed by GitHub
parent 9f3ad5efda
commit 3cdcb2bbb7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 7 additions and 11 deletions

View File

@ -34,8 +34,7 @@ class ServerDecorator extends SimpleDecoratingHttpService {
Context otelContext = Context.current(); Context otelContext = Context.current();
HttpServerRoute.update( HttpServerRoute.update(otelContext, HttpServerRouteSource.SERVER, matchedRoute);
otelContext, HttpServerRouteSource.SERVER, (context, name) -> name, matchedRoute);
try { try {
return unwrap().serve(ctx, req); return unwrap().serve(ctx, req);

View File

@ -34,8 +34,7 @@ public final class FinatraSingletons {
} }
public static void updateServerSpanName(Context context, RouteInfo routeInfo) { public static void updateServerSpanName(Context context, RouteInfo routeInfo) {
HttpServerRoute.update( HttpServerRoute.update(context, HttpServerRouteSource.CONTROLLER, routeInfo.path());
context, HttpServerRouteSource.CONTROLLER, (c, route) -> route.path(), routeInfo);
} }
private FinatraSingletons() {} private FinatraSingletons() {}

View File

@ -41,8 +41,7 @@ public final class RatpackSingletons {
} }
// update the netty server span name; FILTER is probably the best match for ratpack Handlers // update the netty server span name; FILTER is probably the best match for ratpack Handlers
HttpServerRoute.update( HttpServerRoute.update(otelContext, HttpServerRouteSource.SERVER_FILTER, matchedRoute);
otelContext, HttpServerRouteSource.SERVER_FILTER, (context, name) -> name, matchedRoute);
return matchedRoute; return matchedRoute;
} }

View File

@ -38,7 +38,7 @@ final class TracingFilter extends Filter {
scope = context.makeCurrent(); scope = context.makeCurrent();
} }
HttpServerRoute.update(context, CONTROLLER, (ctx, s) -> s, path); HttpServerRoute.update(context, CONTROLLER, path);
Throwable statusThrowable = null; Throwable statusThrowable = null;
try { try {

View File

@ -39,7 +39,7 @@ final class TracingFilter extends Filter {
scope = context.makeCurrent(); scope = context.makeCurrent();
} }
HttpServerRoute.update(context, CONTROLLER, (ctx, s) -> s, path); HttpServerRoute.update(context, CONTROLLER, path);
Throwable statusThrowable = null; Throwable statusThrowable = null;
try { try {

View File

@ -16,8 +16,7 @@ public final class SparkRouteUpdater {
public static void updateHttpRoute(@Nullable RouteMatch routeMatch) { public static void updateHttpRoute(@Nullable RouteMatch routeMatch) {
if (routeMatch != null) { if (routeMatch != null) {
Context context = Context.current(); Context context = Context.current();
HttpServerRoute.update( HttpServerRoute.update(context, HttpServerRouteSource.CONTROLLER, routeMatch.getMatchUri());
context, HttpServerRouteSource.CONTROLLER, (c, r) -> r.getMatchUri(), routeMatch);
} }
} }

View File

@ -110,7 +110,7 @@ public class VaadinHelper {
HttpServerRoute.update( HttpServerRoute.update(
context, context,
HttpServerRouteSource.NESTED_CONTROLLER, HttpServerRouteSource.NESTED_CONTROLLER,
(c, loc) -> ServletContextPath.prepend(c, getSpanNameForLocation(loc)), (ctx, loc) -> ServletContextPath.prepend(ctx, getSpanNameForLocation(loc)),
location); location);
} }