Source:
public List<MetricFamilySamples> collect() { if (configFile != null) { long mtime = configFile.lastModified(); if (mtime > config.lastUpdate) { LOGGER.fine("Configuration file changed, reloading..."); reloadConfig(); } } Receiver receiver = new Receiver(); JmxScraper scraper = new JmxScraper(config.jmxUrl, config.username, config.password, config.ssl, config.whitelistObjectNames, config.blacklistObjectNames, receiver); List<MetricFamilySamples> mfsList = new ArrayList<MetricFamilySamples>(); long start = System.nanoTime(); double error = 0; if ((config.startDelaySeconds == 0) || ((start - createTimeNanoSecs) / 1000000000L >= config.startDelaySeconds)) { try { scraper.doScrape(); } catch (Exception e) { error = 1; StringWriter sw = new StringWriter(); e.printStackTrace(new PrintWriter(sw)); LOGGER.severe("JMX scrape failed: " + sw.toString()); } } mfsList.addAll(receiver.metricFamilySamplesMap.values()); List<MetricFamilySamples.Sample> samples = new ArrayList<MetricFamilySamples.Sample>(); samples.add(new MetricFamilySamples.Sample( "jmx_scrape_duration_seconds", new ArrayList<String>(), new ArrayList<String>(), (System.nanoTime() - start) / 1.0E9)); mfsList.add(new MetricFamilySamples("jmx_scrape_duration_seconds", Type.GAUGE, "Time this JMX scrape took, in seconds.", samples)); samples = new ArrayList<MetricFamilySamples.Sample>(); samples.add(new MetricFamilySamples.Sample( "jmx_scrape_error", new ArrayList<String>(), new ArrayList<String>(), error)); mfsList.add(new MetricFamilySamples("jmx_scrape_error", Type.GAUGE, "Non-zero if this scrape failed.", samples)); return mfsList; }

Target:
public List<MetricFamilySamples> collect() { if (configFile != null) { long mtime = configFile.lastModified(); if (mtime > config.lastUpdate) { LOGGER.fine("Configuration file changed, reloading..."); reloadConfig(); } } Receiver receiver = new Receiver(); JmxScraper scraper = new JmxScraper(config.jmxUrl, config.username, config.password, config.ssl, config.whitelistObjectNames, config.blacklistObjectNames, receiver); long start = System.nanoTime(); double error = 0; if ((config.startDelaySeconds > 0) && ((start - createTimeNanoSecs) / 1000000000L < config.startDelaySeconds)) { throw new IllegalStateException("JMXCollector waiting for startDelaySeconds"); } try { scraper.doScrape(); } catch (Exception e) { error = 1; StringWriter sw = new StringWriter(); e.printStackTrace(new PrintWriter(sw)); LOGGER.severe("JMX scrape failed: " + sw.toString()); } List<MetricFamilySamples> mfsList = new ArrayList<MetricFamilySamples>(); mfsList.addAll(receiver.metricFamilySamplesMap.values()); List<MetricFamilySamples.Sample> samples = new ArrayList<MetricFamilySamples.Sample>(); samples.add(new MetricFamilySamples.Sample( "jmx_scrape_duration_seconds", new ArrayList<String>(), new ArrayList<String>(), (System.nanoTime() - start) / 1.0E9)); mfsList.add(new MetricFamilySamples("jmx_scrape_duration_seconds", Type.GAUGE, "Time this JMX scrape took, in seconds.", samples)); samples = new ArrayList<MetricFamilySamples.Sample>(); samples.add(new MetricFamilySamples.Sample( "jmx_scrape_error", new ArrayList<String>(), new ArrayList<String>(), error)); mfsList.add(new MetricFamilySamples("jmx_scrape_error", Type.GAUGE, "Non-zero if this scrape failed.", samples)); return mfsList; }