public List<MetricFamilySamples> collect() { try (Gauge.Timer timer = METRIC_SCRAPE_DURATION.startTimer()) { METRIC_SCRAPE_REQUESTS.inc(); // Switch report synchronized (this) { final FsImageReporter.Report latestReport = fsImageWatcher.getFsImageReport(); if (latestReport != currentReport) { if (currentReport != null) { currentReport.unregister(); } currentReport = latestReport; currentReport.register(); } } setMetricsFromReport(); } catch (Exception e) { METRIC_SCRAPE_ERROR.inc(); LOGGER.error("FSImage scrape failed", e); } return Collections.emptyList(); // Directly registered counters }