I'm using Spring Boot 2 + Influx + Spring AOP to collect metrics in my system.
SO, i have:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-influx</artifactId>
</dependency>
I have a class that collect this metrics and send to influx, see:
@Aspect
@Configuration
@RequiredArgsConstructor
@Slf4j
public class TimerCounterAspect {
private final MicrometerFactory micrometerFactory;
@Around("@annotation(br.com.myproject.TimerCount)")
public Object around(ProceedingJoinPoint joinPoint) {
Timer.Sample sample = micrometerFactory.starTimer();
micrometerFactory.counterIncrement(joinPoint.getTarget().getClass());
Object oReturn;
try {
oReturn = joinPoint.proceed();
} catch (Throwable throwable) {
micrometerFactory.counterErrorIncrement(joinPoint.getTarget().getClass());
log.error("Falha ao processar JoinPoint", throwable);
throw new RuntimeException(throwable);
} finally {
micrometerFactory.stopTimer(joinPoint.getTarget().getClass(), sample);
}
return oReturn;
}
}
When i send some value to influx this works very well, but spring keep sending "zero values" without my permission, filling my influx database. So my influxDB show something like this:
0
0
0
334 (My sent value)
0
0
0
0
0