Export standard JVM and JGit metrics

Add support for constant metrics.  These are exported values that are
computed only once per process and cannot change without the JVM
shutting down and starting back up again.

Export proc/birth_timestamp as build/label to describe when the
process launched and what version it is.  These are constants.

Add support for CallbackMetric1, allowing for some JVM GC data to be
exported. These can be useful to track Java GC overheads over time.

Export JGit block cache metrics along with high level JVM memory usage.

Change-Id: I9bb24a466eab99cf93358b105ff0c7333bd78ea2
This commit is contained in:
Shawn Pearce
2015-11-11 22:47:21 -08:00
parent b65b83a5f6
commit 98d198c701
14 changed files with 674 additions and 29 deletions

View File

@@ -46,6 +46,27 @@ public abstract class MetricMaker {
String name, Description desc,
Field<F1> field1, Field<F2> field2, Field<F3> field3);
/**
* Constant value that does not change.
*
* @param name unique name of the metric.
* @param value only value of the metric.
* @param desc description of the metric.
*/
public <V> void newConstantMetric(String name, final V value, Description desc) {
desc.setConstant();
@SuppressWarnings("unchecked")
Class<V> type = (Class<V>) value.getClass();
final CallbackMetric0<V> metric = newCallbackMetric(name, type, desc);
newTrigger(metric, new Runnable() {
@Override
public void run() {
metric.set(value);
}
});
}
/**
* Instantaneous reading of a value.
*
@@ -80,6 +101,9 @@ public abstract class MetricMaker {
/** Instantaneous reading of a single value. */
public abstract <V> CallbackMetric0<V> newCallbackMetric(
String name, Class<V> valueClass, Description desc);
public abstract <F1, V> CallbackMetric1<F1, V> newCallbackMetric(
String name, Class<V> valueClass, Description desc,
Field<F1> field1);
/** Connect logic to populate a previously created {@link CallbackMetric}. */
public RegistrationHandle newTrigger(CallbackMetric<?> metric1, Runnable trigger) {