@Test public void autoDiscoversTheRuntimeBean() throws Exception { final Gauge gauge = (Gauge) new JvmAttributeGaugeSet().getMetrics().get(MetricName.build("uptime")); assertThat((Long) gauge.getValue()) .isPositive(); }
@Override public Map<MetricName, Metric> getMetrics() { final Map<MetricName, Metric> gauges = new HashMap<MetricName, Metric>(); gauges.put(MetricName.build("name"), new PersistentGauge<String>() { @Override public String getValue() { return runtime.getName(); } }); gauges.put(MetricName.build("vendor"), new PersistentGauge<String>() { @Override public String getValue() { return String.format(Locale.US, "%s %s %s (%s)", runtime.getVmVendor(), runtime.getVmName(), runtime.getVmVersion(), runtime.getSpecVersion()); } }); gauges.put(MetricName.build("uptime"), new PersistentGauge<Long>() { @Override public Long getValue() { return runtime.getUptime(); } }); return Collections.unmodifiableMap(gauges); }
JvmAttributeGaugeSet implements MetricSet { @Override public Map<MetricName, Metric> getMetrics() { final Map<MetricName, Metric> gauges = new HashMap<MetricName, Metric>(); gauges.put(MetricName.build("name"), new PersistentGauge<String>() { @Override public String getValue() { return runtime.getName(); } }); gauges.put(MetricName.build("vendor"), new PersistentGauge<String>() { @Override public String getValue() { return String.format(Locale.US, "%s %s %s (%s)", runtime.getVmVendor(), runtime.getVmName(), runtime.getVmVersion(), runtime.getSpecVersion()); } }); gauges.put(MetricName.build("uptime"), new PersistentGauge<Long>() { @Override public Long getValue() { return runtime.getUptime(); } }); return Collections.unmodifiableMap(gauges); } }
JvmAttributeGaugeSet implements MetricSet { @Override public Map<MetricName, Metric> getMetrics() { final Map<MetricName, Metric> gauges = new HashMap<MetricName, Metric>(); gauges.put(MetricName.build("name"), new PersistentGauge<String>() { @Override public String getValue() { return runtime.getName(); } }); gauges.put(MetricName.build("vendor"), new PersistentGauge<String>() { @Override public String getValue() { return String.format(Locale.US, "%s %s %s (%s)", runtime.getVmVendor(), runtime.getVmName(), runtime.getVmVersion(), runtime.getSpecVersion()); } }); gauges.put(MetricName.build("uptime"), new PersistentGauge<Long>() { @Override public Long getValue() { return runtime.getUptime(); } }); return Collections.unmodifiableMap(gauges); } JvmAttributeGaugeSet();  JvmAttributeGaugeSet(RuntimeMXBean runtime); }
JvmAttributeGaugeSet implements MetricSet { @Override public Map<MetricName, Metric> getMetrics() { final Map<MetricName, Metric> gauges = new HashMap<MetricName, Metric>(); gauges.put(MetricName.build("name"), new PersistentGauge<String>() { @Override public String getValue() { return runtime.getName(); } }); gauges.put(MetricName.build("vendor"), new PersistentGauge<String>() { @Override public String getValue() { return String.format(Locale.US, "%s %s %s (%s)", runtime.getVmVendor(), runtime.getVmName(), runtime.getVmVersion(), runtime.getSpecVersion()); } }); gauges.put(MetricName.build("uptime"), new PersistentGauge<Long>() { @Override public Long getValue() { return runtime.getUptime(); } }); return Collections.unmodifiableMap(gauges); } JvmAttributeGaugeSet();  JvmAttributeGaugeSet(RuntimeMXBean runtime); @Override Map<MetricName, Metric> getMetrics(); @Override long lastUpdateTime(); }
JvmAttributeGaugeSet implements MetricSet { @Override public Map<MetricName, Metric> getMetrics() { final Map<MetricName, Metric> gauges = new HashMap<MetricName, Metric>(); gauges.put(MetricName.build("name"), new PersistentGauge<String>() { @Override public String getValue() { return runtime.getName(); } }); gauges.put(MetricName.build("vendor"), new PersistentGauge<String>() { @Override public String getValue() { return String.format(Locale.US, "%s %s %s (%s)", runtime.getVmVendor(), runtime.getVmName(), runtime.getVmVersion(), runtime.getSpecVersion()); } }); gauges.put(MetricName.build("uptime"), new PersistentGauge<Long>() { @Override public Long getValue() { return runtime.getUptime(); } }); return Collections.unmodifiableMap(gauges); } JvmAttributeGaugeSet();  JvmAttributeGaugeSet(RuntimeMXBean runtime); @Override Map<MetricName, Metric> getMetrics(); @Override long lastUpdateTime();  }