I want to use Guage metric from DropWizard to monitor my thread pool size.
ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(
2,
2,
1,
TimeUnit.MINUTES,
new ArrayBlockingQueue<Runnable>(100),
new ThreadPoolExecutor.DiscardPolicy());
metricRegistry.register(name(ThreadPoolExecutor.class, "ThreadPoolRemainingCapacity"), (Gauge<Integer>) () -> threadPoolExecutor.getQueue().remainingCapacity());
metricRegistry.register(name(ThreadPoolExecutor.class, "ThreadPoolOccupiedCapacity"), (Gauge<Integer>) () -> threadPoolExecutor.getQueue().size());
return threadPoolExecutor;
From what I understand, this is done automatically in an interval time. But it seems that I don't get any monitoring data for my registered metrics. Although other metrics in my application such as counter and timer work just fine.
Can someone help me where I got it wrong?
Thank you.