countersLock = new ReentrantLock();
histogramsLock = new ReentrantLock();
// Used for writing the json for the metrics (see com.codahale.metrics.servlets.MetricsServlet)
// The "false" is to prevent it from printing out all of the values used in the histograms and timers
this.jsonMapper = new ObjectMapper().registerModule(new MetricsModule(RATE_UNIT, DURATION_UNIT, false));
// Register the JVM memory gauges and prefix the keys
MemoryUsageGaugeSet memorySet = new MemoryUsageGaugeSet();
for (String key : memorySet.getMetrics().keySet()) {
metricRegistry.register(MetricRegistry.name("jvm", "memory", key), memorySet.getMetrics().get(key));