Last active
December 15, 2015 20:19
-
-
Save migue/5317471 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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