LookoutRegistryMetricReader implements MetricReader, MetricRegistryListener { @Override public Iterable<Metric<?>> findAll() { final Iterator<com.alipay.lookout.api.Metric> lookoutIt = this.springBootActuatorRegistry .iterator(); return new Iterable<Metric<?>>() { @Override public Iterator<Metric<?>> iterator() { List<Metric<?>> metricsRes = new LinkedList<Metric<?>>(); while (lookoutIt.hasNext()) { com.alipay.lookout.api.Metric lookoutMetric = lookoutIt.next(); Id id = lookoutMetric.id(); Collection<Metric> metricList = findMetricsById(id); if (metricList != null && metricList.size() > 0) { for (Metric metric : metricList) { metricsRes.add(metric); } } } return metricsRes.iterator(); } }; } 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 testFindAll() throws Exception { Iterable<Metric<?>> metricIterable = this.lookoutRegistryMetricReader.findAll(); List<Metric> metricList = new ArrayList<Metric>(); for (Metric<?> metric : metricIterable) { metricList.add(metric); } assertTrue(metricList.size() > 0); }