@Override
    public List<MetricFamilySamples> collect() {
        ConcurrentMap<String, MetricCalEntity> metricMap = MonitorCacheUtil.getMetric();
        List<MetricFamilySamples> metricFamilySamplesList = new ArrayList<>();
        if (metricMap.isEmpty()) {
            return Collections.EMPTY_LIST;
        }
        long currentTime = System.currentTimeMillis();
        Map<String, MetricCalEntity> currentMap = new HashMap<>();
        for (Map.Entry<String, MetricCalEntity> entry : metricMap.entrySet()) {
            if (entry.getValue() == null || StringUtils.isBlank(entry.getKey())) {
                continue;
            }
            MetricCalEntity metricCalEntity = new MetricCalEntity();
            metricCalEntity.getConsumeReqTimeNum().set(entry.getValue().getConsumeReqTimeNum().get());
            metricCalEntity.getFailedReqNum().set(entry.getValue().getFailedReqNum().get());
            metricCalEntity.getSuccessFulReqNum().set(entry.getValue().getSuccessFulReqNum().get());
            metricCalEntity.getReqNum().set(entry.getValue().getReqNum().get());
            addMetricFamilySamples(metricFamilySamplesList, entry.getKey(), metricCalEntity, currentTime);
            currentMap.put(entry.getKey(), metricCalEntity);
        }
        lastTime = currentTime;
        lastCurrents = currentMap;
        return metricFamilySamplesList;
    }
@Test
    public void testCollect() {
        ServiceCollectorService serviceCollectorService = new ServiceCollectorService();
        List<Collector.MetricFamilySamples> metricFamilySamplesList = serviceCollectorService.collect();
        Assert.assertTrue(metricFamilySamplesList.isEmpty());
        MetricCalEntity metricCalEntity = MonitorCacheUtil.getMetricCalEntity(NANE);
        serviceCollectorService.collect();
        metricCalEntity.getSuccessFulReqNum().addAndGet(REQ_NUM);
        metricCalEntity.getConsumeReqTimeNum().addAndGet(REQ_TIME);
        metricFamilySamplesList = serviceCollectorService.collect();
        Assert.assertFalse(metricFamilySamplesList.isEmpty());
        metricFamilySamplesList.forEach(metricFamilySamples -> {
            Assert.assertNotNull(metricFamilySamples.samples);
            Assert.assertEquals(1, metricFamilySamples.samples.size());
            if (METRIC_NAME.equals(metricFamilySamples.name)){
                Assert.assertEquals(metricFamilySamples.samples.get(0).value, (double) REQ_TIME / REQ_NUM, 0.0);
            }
        });
    }