Source:
<code>protected void initCounters() { <START> metricRegistry.register(MetricRegistry.name(QueryExecutionService.class, QUEUED_QUERIES), new Gauge<Long>() { <END> @Override public Long getValue() { return getQuerySvc().getQueuedQueriesCount(); } }); metricRegistry.register(MetricRegistry.name(QueryExecutionService.class, RUNNING_QUERIES), new Gauge<Long>() { @Override public Long getValue() { return getQuerySvc().getRunningQueriesCount(); } }); metricRegistry.register(MetricRegistry.name(QueryExecutionService.class, FINISHED_QUERIES), new Gauge<Long>() { @Override public Long getValue() { return getQuerySvc().getFinishedQueriesCount(); } }); totalAcceptedQueries = metricRegistry.counter(MetricRegistry.name(QueryExecutionService.class, "total-" + ACCEPTED_QUERIES)); totalSuccessfulQueries = metricRegistry.counter(MetricRegistry.name(QueryExecutionService.class, "total-success-queries")); totalFinishedQueries = metricRegistry.counter(MetricRegistry.name(QueryExecutionService.class, "total-" + FINISHED_QUERIES)); totalFailedQueries = metricRegistry.counter(MetricRegistry.name(QueryExecutionService.class, "total-" + FAILED_QUERIES)); totalCancelledQueries = metricRegistry.counter(MetricRegistry.name(QueryExecutionService.class, "total-" + CANCELLED_QUERIES)); metricRegistry.register("gc", new GarbageCollectorMetricSet()); metricRegistry.register("memory", new MemoryUsageGaugeSet()); metricRegistry.register("threads", new ThreadStatesGaugeSet()); metricRegistry.register("jvm", new JvmAttributeGaugeSet()); }</code><technical_language>store gauge a variable for counters return guage for getter methods</technical_language>

Target:
protected void initCounters() { queuedQueries = metricRegistry.register(MetricRegistry.name(QueryExecutionService.class, QUEUED_QUERIES), new Gauge<Long>() { @Override public Long getValue() { return getQuerySvc().getQueuedQueriesCount(); } }); runningQueries = metricRegistry.register(MetricRegistry.name(QueryExecutionService.class, RUNNING_QUERIES), new Gauge<Long>() { @Override public Long getValue() { return getQuerySvc().getRunningQueriesCount(); } }); finishedQueries = metricRegistry.register(MetricRegistry.name(QueryExecutionService.class, FINISHED_QUERIES), new Gauge<Long>() { @Override public Long getValue() { return getQuerySvc().getFinishedQueriesCount(); } }); totalAcceptedQueries = metricRegistry.counter(MetricRegistry.name(QueryExecutionService.class, "total-" + ACCEPTED_QUERIES)); totalSuccessfulQueries = metricRegistry.counter(MetricRegistry.name(QueryExecutionService.class, "total-success-queries")); totalFinishedQueries = metricRegistry.counter(MetricRegistry.name(QueryExecutionService.class, "total-" + FINISHED_QUERIES)); totalFailedQueries = metricRegistry.counter(MetricRegistry.name(QueryExecutionService.class, "total-" + FAILED_QUERIES)); totalCancelledQueries = metricRegistry.counter(MetricRegistry.name(QueryExecutionService.class, "total-" + CANCELLED_QUERIES)); metricRegistry.register("gc", new GarbageCollectorMetricSet()); metricRegistry.register("memory", new MemoryUsageGaugeSet()); metricRegistry.register("threads", new ThreadStatesGaugeSet()); metricRegistry.register("jvm", new JvmAttributeGaugeSet()); }