我正在尝试通过 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");
}
}
最佳答案
正如 GitHub 问题跟踪器 ( https://github.com/vert-x3/vertx-micrometer-metrics/issues/36 ) 中提到的,这是 micrometrics 1.0.0 版本中的问题。版本升级到1.0.5暂时修复了该bug,等待vertx-micrometer-metrics更新对micrometer的依赖。
关于java - Vertx - InfluxDB 指标保持连接打开,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50945351/