简体   繁体   English

Vertx-InfluxDB指标保持连接打开

[英]Vertx - InfluxDB metrics keeping connection open

I am trying to incorporate metrics reporting into my Vertx application, through an InfluxDB instance. 我正在尝试通过InfluxDB实例将指标报告合并到我的Vertx应用程序中。 However, when I try to gracefully end my application, there is a hanging thread somewhere. 但是,当我尝试正常结束应用程序时,某处有一个挂起的线程。 I managed to track it down to the InfluxDB connection for vertx's metrics reporting, or so it seems, but I don't see a way to kill it off. 我设法将其跟踪到InfluxDB连接以进行vertx的指标报告,或者看起来如此,但是我没有找到杀死它的方法。 Can anyone point me in the right direction? 谁能指出我正确的方向?

A minimal working example (if you disable the metrics, the application gracefully finishes, otherwise, it hangs): 一个最小的工作示例(如果禁用指标,则应用程序正常完成,否则将挂起):

import io.vertx.core.Vertx;
import io.vertx.core.VertxOptions;
import io.vertx.micrometer.MicrometerMetricsOptions;
import io.vertx.micrometer.VertxInfluxDbOptions;
import io.vertx.micrometer.backends.BackendRegistries;

public class MWE {
    public static void main(String[] args) {
        //setting up the metric options for influxdb. seems to work in MWE without credentials
        MicrometerMetricsOptions metricsOptions = new MicrometerMetricsOptions()
                .setRegistryName("data-client")
                .setInfluxDbOptions(new VertxInfluxDbOptions()
                        //disabling this would make sure the application _does_ gracefully exit
                        .setEnabled(true)
                )
                .setEnabled(true);

        //setting up the vertx instance
        Vertx vertx = Vertx.vertx(
                new VertxOptions()
                        .setMetricsOptions(metricsOptions)
                        .setWorkerPoolSize(50)
        );

        //stop vertx after a second
        vertx.setTimer(1000, timerID -> {
            //closing the vertx instance
            vertx.close(result -> System.out.println("Vertx was closed."));
            //closing the registry of metrics to influxdb
            BackendRegistries.getNow("data-client").close();
            System.out.println("Closed everything");
        });

        System.out.println("Done with main");
    }
}

As mentioned in the GitHub issue tracker ( https://github.com/vert-x3/vertx-micrometer-metrics/issues/36 ), this was an issue in version 1.0.0 of micrometrics. 如GitHub问题追踪器( https://github.com/vert-x3/vertx-micrometer-metrics/issues/36 )中所述,这是1.0.0版测微技术中的一个问题。 Bumping the version to 1.0.5 temporarily fixes the bug, awaiting the update of the dependency on micrometer by vertx-micrometer-metrics. 将版本升级到1.0.5可以临时修复该错误,并等待vertx-micrometer-metrics更新对测微表的依赖关系。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM