我正在尝试通过InfluxDB实例将指标报告合并到我的Vertx应用程序中。但是,当我尝试正常结束我的应用程序时,某处有一个挂起的线程。我设法将其跟踪到InfluxDB连接以进行vertx的指标报告,或者看起来如此,但是我没有找到杀死它的方法。谁能指出我正确的方向?
一个最小的工作示例(如果禁用指标,则应用程序会正常完成,否则将挂起):
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");
}
}
相关分类