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");
}
}