Skip to content

Instantly share code, notes, and snippets.

@migue
Last active December 15, 2015 20:19
Show Gist options
  • Save migue/5317471 to your computer and use it in GitHub Desktop.
Save migue/5317471 to your computer and use it in GitHub Desktop.
public class JVMMetric implements Metric {
@Override
public String name() {
return "[JVM-Metric]";
}
@Override
public String display() {
StringBuffer sb = new StringBuffer(4);
sb.append("Metric: " + name() + "\n");
sb.append("Current time: " + System.currentTimeMillis() + "\n");
sb.append("Max memory: " + Runtime.getRuntime().maxMemory() + "\n");
sb.append(
"Available processors: " +
Runtime.getRuntime().availableProcessors() + "\n");
return sb.toString();
}
}
public class JVMMetricsProvider implements MetricsProvider {
@Override
public Metric collect() {
return new JVMMetric();
}
@Override
public Map<String, Object> getMetricProperties() {
return new HashMap<String, Object>();
}
@Override
public Long getId() {
return 1L;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment