There has been a bunch of work going on in the area of measuring Java.
Dropwizard Metrics in Java using Gauges and Counters
In the interest of learning how to do in-line instrumentation with Java, I started the following project on GitHub. I'll continue to refine it over time. It uses Dropwizard Metrics, which, while a good set of libraries overall, is a bit complicated. Nebertheless, the full code is here.
A More Sophisticated Example
Doing bytecode instrumentation in Java with annotations and Dropwizard
Note this is a work in progress. Will be completed shortly.