带标签的计数器 - 如何按 dimension/tag 分组?
Counter with tags - How to group by dimension/tag?
我试图通过 dimension/tag 功能来理解 spring 微博评论者的群组。我正在使用 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
我的理解正确吗?或者我如何通过功能实现分组(或)select?
您可以通过带有 MeterRegistry.find()
的标签查找 Counter
并自行汇总。 AFAICT 没有开箱即用的标签聚合值支持,我希望聚合发生在监控系统中。
请参阅 this test 了解其工作原理。
我试图通过 dimension/tag 功能来理解 spring 微博评论者的群组。我正在使用 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
我的理解正确吗?或者我如何通过功能实现分组(或)select?
您可以通过带有 MeterRegistry.find()
的标签查找 Counter
并自行汇总。 AFAICT 没有开箱即用的标签聚合值支持,我希望聚合发生在监控系统中。
请参阅 this test 了解其工作原理。