在spring-cloud-gateway项目中整合actuator后,通过调用/actuator/prometheus接口可以拿到service的一些性能指标
针对其中一项 http_service_requests的信息,其中通过gateway动态配置的url无法拿到具体的请求URL,springboot框架给出了UNKNOW
具体可以参考此link: github.com/spring-projects/spring-boot/issues/16208
这是springboot为了规范url所作出的一些处理,spring-boot的维护人员不想改动这个地方,所以如果我们有需要将url的具体信息记录下来,可以重写一个httpRequestTags方法加入自己的逻辑,具体如下:
public class MyWebFluxTags implements WebFluxTagsContributor{
@Override
public Iterable<Tag> httpRequestTags(ServerWebExchange exchange, Throwable ex){
String path = exchange.getRequest().getPath().value();
Tag uri = Tag.of("uri", path);
return Lists.newArrayList(uri);
}
}
其中的path就是拿到了具体请求到gateway的request url, 覆盖掉原先的UNKNOW url