LookoutRegistryMetricReader implements MetricReader, MetricRegistryListener { @Override public Metric<?> findOne(String metricName) { if (StringUtils.isBlank(metricName)) { return null; } Id id = this.springBootActuatorRegistry.createId(metricName); List<Metric> metricList = findMetricsById(id); if (metricList != null && metricList.size() > 0) { return metricList.get(0); } else { return null; } } LookoutRegistryMetricReader(SpringBootActuatorRegistry springBootActuatorRegistry); @Override Metric<?> findOne(String metricName); @Override Iterable<Metric<?>> findAll(); @Override long count(); @Override void onRemoved(com.alipay.lookout.api.Metric metric); @Override void onAdded(com.alipay.lookout.api.Metric metric);  }
@Test public void testFindOne() throws Exception { assertNull(lookoutRegistryMetricReader.findOne("")); assertTrue(this.metricReaderPublicMetrics != null && this.metricReaderPublicMetrics.size() > 0); assertNotNull(testRestTemplate); String endpointId = "mappings"; String restUrl = urlHttpPrefix + "/" + endpointId; ResponseEntity<String> response = testRestTemplate.getForEntity(restUrl, String.class); assertTrue(StringUtils.isNotBlank(response.getBody())); Metric metric = this.lookoutRegistryMetricReader .findOne(LookoutSpringBootMetricsImpl.LOOKOUT_GAUGE_PREFIX + "response." + endpointId); assertTrue(metric != null); }