我正在使用Spring Boot Actuator +千分尺将值发送到千分尺,所以我有以下想法:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-influx</artifactId>
</dependency>
所以,我有一种启动计时器和停止计时器样本(千分尺)的方法:
public Timer.Sample starTimer() {
return Timer.start(registry);
}
public void stopTimer(Class clazz, Timer.Sample sample) {
sample.stop(registry.timer("timer-dev", Arrays.asList(Tag.of("modulo", modulo), Tag.of("class", clazz.getName()))));
}
所以,这很好。 InfluxDB接收从Spring Boot Application发送的值,并在Grafana中显示。
问题::首次发送“ timer-dev”进入系统后,spring boot持续发送值“ 0”,我想避免spring boot发送零值,它应该仅在timer-dev大于零。仅在不每次调用此方法时才发送“ timer-dev”。
任何提示?