public static void incrementIpCountWithBatchRegister(InstancePublishInfo old,
            BatchInstancePublishInfo instancePublishInfo) {
        int newSize = instancePublishInfo.getInstancePublishInfos().size();
        if (null == old) {
            // First time increment batchPublishInfo, add all into metrics.
            getIpCountMonitor().addAndGet(newSize);
        } else if (old instanceof BatchInstancePublishInfo) {
            // Not first time increment batchPublishInfo, calculate the diff, and add the diff to metrics, the diff may be negative.
            int oldSize = ((BatchInstancePublishInfo) old).getInstancePublishInfos().size();
            getIpCountMonitor().addAndGet(newSize - oldSize);
        } else {
            // Not first time increment batchPublishInfo and the old one is not batch, also diff it.
            getIpCountMonitor().addAndGet(newSize - 1);
        }
    }
@Test
    void testIncrementIpCountWithBatchRegister() {
        BatchInstancePublishInfo test = new BatchInstancePublishInfo();
        List<InstancePublishInfo> instancePublishInfos = new LinkedList<>();
        instancePublishInfos.add(new InstancePublishInfo());
        test.setInstancePublishInfos(instancePublishInfos);
        assertEquals(0, MetricsMonitor.getIpCountMonitor().get());
        MetricsMonitor.incrementIpCountWithBatchRegister(null, test);
        assertEquals(1, MetricsMonitor.getIpCountMonitor().get());
        
        BatchInstancePublishInfo newTest = new BatchInstancePublishInfo();
        List<InstancePublishInfo> newInstances = new LinkedList<>();
        newInstances.add(new InstancePublishInfo());
        newInstances.add(new InstancePublishInfo());
        newTest.setInstancePublishInfos(newInstances);
        MetricsMonitor.incrementIpCountWithBatchRegister(test, newTest);
        assertEquals(2, MetricsMonitor.getIpCountMonitor().get());
        MetricsMonitor.incrementIpCountWithBatchRegister(newTest, test);
        assertEquals(1, MetricsMonitor.getIpCountMonitor().get());
    }