我已经使用Inspaut 3.10启动并运行了一个REST API服务,并且正在创建一个仪表板来查看每个端点获得的流量.
目前我们将每个请求路径记录为这样:
@Filter("/**")
@Slf4j
public class LoggingInterceptor implements HttpServerFilter {
@Override
public Publisher<MutableHttpResponse<?>> doFilter(HttpRequest<?> request,
ServerFilterChain chain) {
log.atInfo().addKeyValue("path", request.getPath());
}
}
当每个请求的路径相同时,这非常有效,例如:
GET /api/users
在日志(log)记录仪表板中,我可以通过上述路径对请求进行分组,它将与到达该端点的请求数量完全匹配.
但当路径中有路径参数时,例如:
GET /api/users/{userId}
那么按记录的请求路径分组就没有那么有用了,因 for each 实际请求看起来像这样:
GET /api/users/UserId123
GET /api/users/UserId234
GET /api/users/UserId345
...
因此,在我按请求路径对日志(log)进行分组的仪表板中,我似乎有数百个对路径/api/users
的请求,但只有1-2个对数百个不同路径(例如/api/users/UserId123
、/api/users/UserId234
)的请求.理想情况下,我可以将这些人集中在/api/users/{userId}
以下.
我的实际问题是:
Is there a way to get the path from the request with 100 instead of 101?为此目的,了解什么是wildcard path of the controller that Micronaut resolved the current request to,而不是请求的实际URL路径将非常有用.这可能吗?