【发布时间】:2021-07-08 09:09:11
【问题描述】:
我正在尝试使用 Java 库“io.micrometer.core.instrument”来计算不同时间间隔内的一些值。
所以使用 Counter 我的代码如下所示:
private MeterRegistry meterRegistry;
private Counter attemptsCount;
@PostConstruct
private void initCounter() {
attemptsCount = Counter.builder("ATTEMPTS_COUNT")
.tag("type", "word")
.description("Attempts number count")
.register(meterRegistry);
}
public void incrementAttemptsCount(final int sendAttemptsCount) {
attemptsCount.increment(sendAttemptsCount);
attemptsCount.count();
}
在测试用例客户端代码中,3 次传递给 incrementAttemptsCount-method 以下值:3、3、3。
最初我预计,我的千分尺代码会生成 3 个度量值:3、3、3,并将其传递给 Prometheus。而且,使用 Graphana 工具,我将看到反映离散值的直方图。像这样的:
但我看到的不是这个:
所以它整合了值 (3+3+3) 和输出 9。
如何提供度量 (3, 3, 3) 的离散值的输出?我应该使用什么仪器?
【问题讨论】:
标签: java prometheus micrometer