Source:
<code>public void prepare(final Map<String, Object> topoConf, TopologyContext context, OutputCollector collector) { if (prepareWasCalled && !"local".equals(topoConf.get(Config.STORM_CLUSTER_MODE))) { throw new RuntimeException("A single worker should have 1 SystemBolt instance."); } prepareWasCalled = true; int bucketSize = ObjectReader.getInt(topoConf.get(Config.TOPOLOGY_BUILTIN_METRICS_BUCKET_SIZE_SECS)); @SuppressWarnings("checkstyle:AbbreviationAsWordInName") <START> final RuntimeMXBean jvmRT = ManagementFactory.getRuntimeMXBean(); <END> context.registerMetric("uptimeSecs", () -> jvmRT.getUptime() / 1000.0, bucketSize); context.registerMetric("startTimeSecs", () -> jvmRT.getStartTime() / 1000.0, bucketSize); final ThreadMXBean threadBean = ManagementFactory.getThreadMXBean(); context.registerMetric("threadCount", threadBean::getThreadCount, bucketSize); context.registerMetric("newWorkerEvent", new IMetric() { boolean doEvent = true; @Override public Object getValueAndReset() { if (doEvent) { doEvent = false; return 1; } else { return 0; } } }, bucketSize); @SuppressWarnings("checkstyle:AbbreviationAsWordInName") final MemoryMXBean jvmMemRT = ManagementFactory.getMemoryMXBean(); context.registerMetric("memory/heap", new MemoryUsageMetric(jvmMemRT::getHeapMemoryUsage), bucketSize); context.registerMetric("memory/nonHeap", new MemoryUsageMetric(jvmMemRT::getNonHeapMemoryUsage), bucketSize); for (GarbageCollectorMXBean b : ManagementFactory.getGarbageCollectorMXBeans()) { context.registerMetric("GC/" + b.getName().replaceAll("\\W", ""), new GarbageCollectorMetric(b), bucketSize); } registerMetrics(context, (Map<String, String>) topoConf.get(Config.WORKER_METRICS), bucketSize, topoConf); registerMetrics(context, (Map<String, String>) topoConf.get(Config.TOPOLOGY_WORKER_METRICS), bucketSize, topoConf); }</code><technical_language>This is part of API, rename</technical_language>

Target:
public void prepare(final Map<String, Object> topoConf, TopologyContext context, OutputCollector collector) { if (prepareWasCalled && !"local".equals(topoConf.get(Config.STORM_CLUSTER_MODE))) { throw new RuntimeException("A single worker should have 1 SystemBolt instance."); } prepareWasCalled = true; int bucketSize = ObjectReader.getInt(topoConf.get(Config.TOPOLOGY_BUILTIN_METRICS_BUCKET_SIZE_SECS)); final RuntimeMXBean jvmRt = ManagementFactory.getRuntimeMXBean(); context.registerMetric("uptimeSecs", () -> jvmRt.getUptime() / 1000.0, bucketSize); context.registerMetric("startTimeSecs", () -> jvmRt.getStartTime() / 1000.0, bucketSize); final ThreadMXBean threadBean = ManagementFactory.getThreadMXBean(); context.registerMetric("threadCount", threadBean::getThreadCount, bucketSize); context.registerMetric("newWorkerEvent", new IMetric() { boolean doEvent = true; @Override public Object getValueAndReset() { if (doEvent) { doEvent = false; return 1; } else { return 0; } } }, bucketSize); @SuppressWarnings("checkstyle:AbbreviationAsWordInName") final MemoryMXBean jvmMemRT = ManagementFactory.getMemoryMXBean(); context.registerMetric("memory/heap", new MemoryUsageMetric(jvmMemRT::getHeapMemoryUsage), bucketSize); context.registerMetric("memory/nonHeap", new MemoryUsageMetric(jvmMemRT::getNonHeapMemoryUsage), bucketSize); for (GarbageCollectorMXBean b : ManagementFactory.getGarbageCollectorMXBeans()) { context.registerMetric("GC/" + b.getName().replaceAll("\\W", ""), new GarbageCollectorMetric(b), bucketSize); } registerMetrics(context, (Map<String, String>) topoConf.get(Config.WORKER_METRICS), bucketSize, topoConf); registerMetrics(context, (Map<String, String>) topoConf.get(Config.TOPOLOGY_WORKER_METRICS), bucketSize, topoConf); }