如何使用Spring Boot';在http客户端请求度量的uri标记中获取模板值;什么是REST模板?

如何使用Spring Boot';在http客户端请求度量的uri标记中获取模板值;什么是REST模板?,spring,spring-boot,resttemplate,spring-boot-actuator,spring-micrometer,Spring,Spring Boot,Resttemplate,Spring Boot Actuator,Spring Micrometer,我们使用Spring Boot 2.1.4和测微计注册表prometheus依赖项来捕获度量 我们有一个例子,Spring引导服务使用RestTemplate调用另一个服务。此调用生成的度量包含URI中的实际值,而不是模板值 例如,在/exactor/prometheus端点中,我看到如下条目: http\u client\u requests\u seconds\u count{clientName=“someClient”,method=“GET”,status=“200”,uri=“/pe

我们使用Spring Boot 2.1.4和
测微计注册表prometheus
依赖项来捕获度量

我们有一个例子,Spring引导服务使用RestTemplate调用另一个服务。此调用生成的度量包含URI中的实际值,而不是模板值

例如,在
/exactor/prometheus
端点中,我看到如下条目:

http\u client\u requests\u seconds\u count{clientName=“someClient”,method=“GET”,status=“200”,uri=“/person/lookup?firstName=Tony&lastName=Soprano”}1.0

根据文档,我希望看到的是变量名而不是值,如下所示:

http\u client\u requests\u seconds\u count{clientName=“someClient”,method=“GET”,status=“200”,uri=“/person/lookup?firstName={firstName}&lastName={lastName}”,}1.0

是否有方法获取默认的
http.client.requests
metric值以使用URI标记的模板值

位于的Spring文档说明了uri标记:

如果可能的话,在变量替换之前请求的URI模板(例如,/api/person/{id})


如何使变量替换成为可能?

我假设您正在使用
restemplatebuilder
构建
restemplate
,否则您将无法注册度量

您是否真的将模板化url传递到
restemplate
s交换方法中,并传递参数以进行子排序?在
2.1.4.发行版
2.2.1.发行版
上对我有效

    template.getForObject("http://localhost:" + this.serverPort + "/hello/{id}",
            String.class, Collections.singletonMap("id", "loop"));
结果:

http_client_requests_seconds_count{application="micrometered2",clientName="localhost",method="GET",outcome="SUCCESS",status="200",uri="/hello/{id}",} 23.0

好的,它打算为每个调用使用的值创建单独的日志。但是,Grafana等监控工具有助于以通用方式显示结果。IMHO,如果日志中没有值,则很难计算出度量结果。@RaufAgayev如果我们调用{id}1000次,实际上它会在性能问题中为度量和结果创建1000个条目