use of org.janusgraph.util.stats.MetricManager in project janusgraph by JanusGraph.
the class MetricInstrumentedStore method runWithMetrics.
static <T> void runWithMetrics(String prefix, String name, IOCallable<T> impl) throws IOException {
if (null == prefix) {
impl.call();
return;
}
Preconditions.checkNotNull(name);
Preconditions.checkNotNull(impl);
final MetricManager mgr = MetricManager.INSTANCE;
mgr.getCounter(prefix, null, MetricInstrumentedIterator.M_CLOSE, M_CALLS).inc();
final Timer.Context tc = mgr.getTimer(prefix, null, MetricInstrumentedIterator.M_CLOSE, M_TIME).time();
try {
impl.call();
} catch (IOException e) {
mgr.getCounter(prefix, null, MetricInstrumentedIterator.M_CLOSE, M_EXCEPTIONS).inc();
throw e;
} finally {
tc.stop();
}
}
Aggregations