Added a framework for metrics
Added a metrics framework based on the codahale Metrics
package. ONOS can create a registry and maintain Metrics,
as well as dump out metrics values via a REST API. Unit
tests are include that test the REST APIs. Currently
supports Timers, Counters, Gauges, Meters, and Histograms.
Change-Id: I0f6ed87f889dc7037caf9aefc92e663702c6dda8
diff --git a/src/main/java/net/onrc/onos/core/metrics/OnosMetrics.java b/src/main/java/net/onrc/onos/core/metrics/OnosMetrics.java
new file mode 100644
index 0000000..bfd603f
--- /dev/null
+++ b/src/main/java/net/onrc/onos/core/metrics/OnosMetrics.java
@@ -0,0 +1,28 @@
+package net.onrc.onos.core.metrics;
+
+import com.codahale.metrics.MetricRegistry;
+
+/**
+ * This class acts a singleton to hold the Metrics registry for ONOS.
+ */
+public final class OnosMetrics {
+
+ /**
+ * Hide constructor. The only way to get the registry is through the
+ * singleton getter.
+ */
+ private OnosMetrics() {}
+
+ private static final MetricRegistry METRICS_REGISTRY = new MetricRegistry();
+
+ /**
+ * Get the singleton Metrics registry. A single instance of
+ * the registry is statically allocated and then used by all callers.
+ *
+ * @return Metrics registry
+ */
+ public static MetricRegistry getMetricsRegistry() {
+ return METRICS_REGISTRY;
+ }
+}
+