如何设置 MeterRegistry httpRequest 指标的名称?



大家晚上好。 我创建了GraphiteMeterRegistry bean。

@Bean
public GraphiteMeterRegistry meterRegistry(GraphiteConfig graphiteConfig) {
String host;
try {
host = InetAddress.getLocalHost().getHostName().replaceAll("\.","_");
} catch (UnknownHostException e) {
host = "test";
log.warn("Host wasn't found", e);
}
String prefix = "lm." + host + ".";
return new GraphiteMeterRegistry(graphiteConfig, Clock.SYSTEM,
(id, convention) -> prefix + HierarchicalNameMapper.DEFAULT.toHierarchicalName(id, convention));
}

它发送默认的stas,jvm,hiharicp,http和e.t.c,这很好。但是当我想获取有关我的端点(称为"myendpoint"(的httpRequests的信息时,我发现它不是存储在myendpoint文件夹中,而是存储在每个id的百万文件夹中(作为参数获得(。例如:

myendpoint&id=12345679
myendpoint&id=12345672
myendpoint&id=12345673
myendpoint&id=12345671 

但我希望这个名称对于同一个端点是相同的。你如何配置它?

Spring doc 说:

要自定义标签,并根据您选择的客户端,您可以 提供@Bean实现 RestTemplateExchangeTagsProvider 或 WebClientExchangeTagsProvider.

这里的问题是,如果你使用 servlet,而不是反应式的,你将需要实现的不是WebClientExchangeTagsProvider,而是WebMvcTagsProvider@Bean。

最新更新