java为springboot中的graphite测微计事件添加前缀
我将spring-boot 2
与graphite
一起使用。我想为我的所有指标添加一个前缀
@Bean
public MeterRegistry graphiteRegistsry() {
return new GraphiteMeterRegistry(
GraphiteConfig.DEFAULT, Clock.SYSTEM,
(id, convention) -> "prefix." +
HierarchicalNameMapper.DEFAULT.toHierarchicalName(id,convention));
}
如果我使用这段代码,这实际上是添加前缀,但也创建了一些没有前缀的度量。看起来他们几乎所有的指标都是重复的
如何添加此前缀?从这个应用程序到graphite的所有指标都将包含前缀
谢谢
# 1 楼答案
首先,您可以使用
MeterRegistryCustomizer
添加公共标记:其次,扩展应用程序属性,将此标记转换为前缀:
请看详细的解释here