metrics-perf
is a tiny extension to yammer's metrics library exporting all metrics as Hotspot perf counters.
You can safely use this on a non-Hotspot VM as all Hotspot specific calls are done via reflection (i.e. no static import) and only executed if a compliant VM is detected.
To export all your metrics simply add this code:
final PerfReporter reporter = new PerfReporter(Metrics.defaultRegistry());
reporter.start(1, TimeUnit.SECONDS);
All perf counters values will then be updated every seconds.
Add following dependency to your pom.xml:
...
<dependency>
<groupId>com.github.jeluard</groupId>
<artifactId>metrics-perf</artifactId>
<version>0.9</version>
</dependency>
...
Perf counters can be visualized by mainly 2 tools: VisualVM and jstat.
VisualVM can visualize perf counters via the tracer plugin.
jstat is a command line tool allowing to track perf counter values.
List all perf counters:
jstat -J-Djstat.showUnsupported=true -list <vmid>
List all exported metrics:
jstat -J-Djstat.showUnsupported=true -snap -name metric.\* <vmid>
Print current value of a particular metric:
jstat -J-Djstat.showUnsupported=true -snap -name metric.metric-name.15min-rate <vmid>
Sample value of a specific metric every 1 second:
jstat -J-Djstat.showUnsupported=true -name metric.metric-name.15min-rate <vmid> 1s
You can find all jstat options (including non-documented) by browsing its source code.