Search in sources :

Example 6 with MetricManager

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();
    }
}
Also used : MetricManager(org.janusgraph.util.stats.MetricManager) Timer(com.codahale.metrics.Timer) IOException(java.io.IOException)

Aggregations

MetricManager (org.janusgraph.util.stats.MetricManager)6 Timer (com.codahale.metrics.Timer)5 BackendException (org.janusgraph.diskstorage.BackendException)2 IOException (java.io.IOException)1