1

I am trying to incorporate metrics reporting into my Vertx application, through an InfluxDB instance. 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. 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");
    }
}
4

1 回答 1

0

正如 GitHub 问题跟踪器 ( https://github.com/vert-x3/vertx-micrometer-metrics/issues/36 ) 中所述,这是 micrometrics 1.0.0 版中的一个问题。将版本升级到 1.0.5 暂时修复了该错误,等待 vertx-micrometer-metrics 更新对 micrometer 的依赖关系。

于 2018-06-25T11:57:51.470 回答