2

我正在尝试按维度/标签功能来了解 spring micromenter 的组。我正在使用 StepMeterRegistry 并增加计数器,但没有看到想要的结果。

创建计数器,

final MeterRegistry myRegistry = new StepMeterRegistry(config, Clock.SYSTEM) {...};

final Counter myCounter1 = myRegistry.counter("myTestCounter", "tag1", "value1");
final Counter myCounter2 = myRegistry.counter("myTestCounter", "tag2", "value2");
final Counter myCounter1n2 = myRegistry.counter("myTestCounter", "tag1", "value1", "tag2", "value2");

递增计数器,

myCounter1.increment();
myCounter2.increment();
myCounter1n2.increment();

当我打印时(在步骤持续时间之后),

myCounter1.measure(); => value=1.0
myCounter2.measure(); => value=1.0
myCounter1n2.measure(); => value=1.0

而我期待(在步骤持续时间之后),

myCounter1.measure(); => value=2.0
myCounter2.measure(); => value=2.0
myCounter1n2.measure(); => value=1.0

我的理解正确吗?或者我怎样才能实现分组(或)按功能选择?

4

1 回答 1

6

Counter您可以通过标签找到sMeterRegistry.find()并自行聚合它们。AFAICT 没有对标签聚合值的开箱即用支持,我希望聚合发生在监控系统中。

请参阅此测试以了解其工作原理。

于 2018-10-16T22:27:57.307 回答