@Override
    public List<MetricSample> sample() {
        List<MetricSample> metricSamples = new ArrayList<>();

        sampleThreadPoolExecutor.forEach((name, executor) -> {
            metricSamples.addAll(createMetricsSample(name, executor));
        });

        return metricSamples;
    }
@Test
    void testSample() {

        ExecutorService executorService = java.util.concurrent.Executors.newFixedThreadPool(5);
        ThreadPoolExecutor threadPoolExecutor = (ThreadPoolExecutor) executorService;
        sampler.addExecutors("testPool", executorService);

        List<MetricSample> metricSamples = sampler.sample();

        Assertions.assertEquals(6, metricSamples.size());

        boolean coreSizeFound = false;
        boolean maxSizeFound = false;
        boolean activeSizeFound = false;
        boolean threadCountFound = false;
        boolean queueSizeFound = false;
        boolean largestSizeFound = false;

        for (MetricSample sample : metricSamples) {
            ThreadPoolMetric threadPoolMetric = ((ThreadPoolMetric) ((GaugeMetricSample) sample).getValue());
            switch (sample.getName()) {
                case "dubbo.thread.pool.core.size":
                    coreSizeFound = true;
                    Assertions.assertEquals(5, threadPoolMetric.getCorePoolSize());
                    break;
                case "dubbo.thread.pool.largest.size":
                    largestSizeFound = true;
                    Assertions.assertEquals(0, threadPoolMetric.getLargestPoolSize());
                    break;
                case "dubbo.thread.pool.max.size":
                    maxSizeFound = true;
                    Assertions.assertEquals(5, threadPoolMetric.getMaximumPoolSize());
                    break;
                case "dubbo.thread.pool.active.size":
                    activeSizeFound = true;
                    Assertions.assertEquals(0, threadPoolMetric.getActiveCount());
                    break;
                case "dubbo.thread.pool.thread.count":
                    threadCountFound = true;
                    Assertions.assertEquals(0, threadPoolMetric.getPoolSize());
                    break;
                case "dubbo.thread.pool.queue.size":
                    queueSizeFound = true;
                    Assertions.assertEquals(0, threadPoolMetric.getQueueSize());
                    break;
            }
        }

        Assertions.assertTrue(coreSizeFound);
        Assertions.assertTrue(maxSizeFound);
        Assertions.assertTrue(activeSizeFound);
        Assertions.assertTrue(threadCountFound);
        Assertions.assertTrue(queueSizeFound);
        Assertions.assertTrue(largestSizeFound);

        executorService.shutdown();
    }