@GetMapping(value = ApiConstants.PROMETHEUS_CONTROLLER_PATH, produces = "application/json; charset=UTF-8")
    public ResponseEntity<String> metric() throws NacosException {
        ArrayNode arrayNode = JacksonUtils.createEmptyArrayNode();
        Set<Instance> targetSet = new HashSet<>();
        Set<String> allNamespaces = serviceManager.getAllNamespaces();
        for (String namespace : allNamespaces) {
            Set<Service> singletons = serviceManager.getSingletons(namespace);
            for (Service service : singletons) {
                
                List<? extends Instance> instances = instanceServiceV2.listAllInstances(namespace,
                        service.getGroupedServiceName());
                
                targetSet.addAll(instances);
                
            }
        }
        
        PrometheusUtils.assembleArrayNodes(targetSet, arrayNode);
        return ResponseEntity.ok().body(arrayNode.toString());
    }
@Test
    public void testMetric() throws Exception {
        when(instanceServiceV2.listAllInstances(nameSpace, NamingUtils.getGroupedName(name, group))).thenReturn(testInstanceList);
        MockHttpServletRequestBuilder builder = MockMvcRequestBuilders.get(ApiConstants.PROMETHEUS_CONTROLLER_PATH);
        MockHttpServletResponse response = mockMvc.perform(builder).andReturn().getResponse();
        assertEquals(200, response.getStatus());
        assertEquals(testInstanceList.size(), JacksonUtils.toObj(response.getContentAsString()).size());
    }