如何查找 hystrix 线程池中的活动线程数?

How to find the number of active threads in a hystrix thread pool?

我正在尝试微调 hystrix 线程池核心大小和最大大小。为此,我需要随时了解并绘制池中活动线程的数量。有办法吗?

这是正确的方法吗?

HystrixThreadPoolKey hystrixThreadPoolKey = new HystrixThreadPoolKey() {
            @Override
            public String name() {
                return threadPoolKey;
            }
        };
HystrixThreadPoolMetrics hystrixThreadPoolMetrics = HystrixThreadPoolMetrics.getInstance(hystrixThreadPoolKey);
log.info("Hystrix active threads: {}", hystrixThreadPoolMetrics.getCurrentActiveCount().toString());

我不确定,因为当我使用它时,当 corePoolSize 设置为 10 时,活动线程数为 0。

这段代码工作正常(在对时间进行空检查之后直到没有请求发出)。但是正确的方法应该是使用Netflix的伺服。

Netflix Announcement

引用公告中的部分内容:

Servo 旨在让开发人员能够轻松地从他们的应用程序代码中导出指标,使用 JMX 注册它们,并将它们发布到外部监控系统

(活动线程池大小也可以小于核心大小)