簡體   English   中英

千分尺發送指標為零-Spring Boot

[英]Micrometer sending metrics zero - Spring Boot

我正在使用Spring Boot 2 + Influx + Spring AOP來收集系統中的指標。

所以我有:

<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-aop</artifactId>
        </dependency>


        <dependency>
            <groupId>io.micrometer</groupId>
            <artifactId>micrometer-registry-influx</artifactId>
        </dependency>

我有一個收集此指標並發送給Influx的類,請參閱:

@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;
    }
}

當我向Influx發送一些值時,效果很好,但是在未經我允許的情況下,Spring繼續發送“零值”,從而填充了我的Influx數據庫。 所以我的influxDB顯示如下:

0
0
0
334 (My sent value)
0
0
0
0
0

您可以在yml文件中進行這樣的配置。

 management: metrics: export: influx: uri: http://localhost:8086 db: mydbName step: 10s 

步長值應與您的預期流量相關。 這樣您就不會在其中看到90%的零。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM