Search in sources :

Example 1 with MetricManager

use of com.thinkaurelius.titan.util.stats.MetricManager in project titan by thinkaurelius.

the class MetricInstrumentedStore method runWithMetrics.

static <T> T runWithMetrics(StoreTransaction txh, String storeName, String name, StorageCallable<T> impl) throws BackendException {
    if (!txh.getConfiguration().hasGroupName()) {
        return impl.call();
    }
    String prefix = txh.getConfiguration().getGroupName();
    Preconditions.checkNotNull(name);
    Preconditions.checkNotNull(impl);
    final MetricManager mgr = MetricManager.INSTANCE;
    mgr.getCounter(prefix, storeName, name, M_CALLS).inc();
    final Timer.Context tc = mgr.getTimer(prefix, storeName, name, M_TIME).time();
    try {
        return impl.call();
    } catch (BackendException e) {
        mgr.getCounter(prefix, storeName, name, M_EXCEPTIONS).inc();
        throw e;
    } catch (RuntimeException e) {
        mgr.getCounter(prefix, storeName, name, M_EXCEPTIONS).inc();
        throw e;
    } finally {
        tc.stop();
    }
}
Also used : MetricManager(com.thinkaurelius.titan.util.stats.MetricManager) Timer(com.codahale.metrics.Timer) BackendException(com.thinkaurelius.titan.diskstorage.BackendException)

Example 2 with MetricManager

use of com.thinkaurelius.titan.util.stats.MetricManager in project titan by thinkaurelius.

the class MetricInstrumentedStoreManager method mutateMany.

@Override
public void mutateMany(Map<String, Map<StaticBuffer, KCVMutation>> mutations, StoreTransaction txh) throws BackendException {
    if (!txh.getConfiguration().hasGroupName()) {
        backend.mutateMany(mutations, txh);
    }
    String prefix = txh.getConfiguration().getGroupName();
    final MetricManager mgr = MetricManager.INSTANCE;
    mgr.getCounter(prefix, managerMetricsName, M_MUTATE, M_CALLS).inc();
    final Timer.Context tc = mgr.getTimer(prefix, managerMetricsName, M_MUTATE, M_TIME).time();
    try {
        backend.mutateMany(mutations, txh);
    } catch (BackendException e) {
        mgr.getCounter(prefix, managerMetricsName, M_MUTATE, M_EXCEPTIONS).inc();
        throw e;
    } catch (RuntimeException e) {
        mgr.getCounter(prefix, managerMetricsName, M_MUTATE, M_EXCEPTIONS).inc();
        throw e;
    } finally {
        tc.stop();
    }
}
Also used : MetricManager(com.thinkaurelius.titan.util.stats.MetricManager) Timer(com.codahale.metrics.Timer) BackendException(com.thinkaurelius.titan.diskstorage.BackendException)

Example 3 with MetricManager

use of com.thinkaurelius.titan.util.stats.MetricManager in project titan by thinkaurelius.

the class MetricInstrumentedStore method runWithMetrics.

static <T> T runWithMetrics(String prefix, String storeName, String name, UncheckedCallable<T> impl) {
    if (null == prefix) {
        return impl.call();
    }
    Preconditions.checkNotNull(name);
    Preconditions.checkNotNull(impl);
    final MetricManager mgr = MetricManager.INSTANCE;
    mgr.getCounter(prefix, storeName, name, M_CALLS).inc();
    final Timer.Context tc = mgr.getTimer(prefix, storeName, name, M_TIME).time();
    try {
        return impl.call();
    } catch (RuntimeException e) {
        mgr.getCounter(prefix, storeName, name, M_EXCEPTIONS).inc();
        throw e;
    } finally {
        tc.stop();
    }
}
Also used : MetricManager(com.thinkaurelius.titan.util.stats.MetricManager) Timer(com.codahale.metrics.Timer)

Example 4 with MetricManager

use of com.thinkaurelius.titan.util.stats.MetricManager in project titan by thinkaurelius.

the class MetricsQueryExecutor method runWithMetrics.

private <T> T runWithMetrics(String opName, Function<Void, T> impl) {
    Preconditions.checkNotNull(opName);
    Preconditions.checkNotNull(impl);
    final MetricManager mgr = MetricManager.INSTANCE;
    mgr.getCounter(metricsPrefix, opName, M_CALLS).inc();
    final Timer.Context tc = mgr.getTimer(metricsPrefix, opName, M_TIME).time();
    try {
        return impl.apply(null);
    } catch (RuntimeException e) {
        mgr.getCounter(metricsPrefix, opName, M_EXCEPTIONS).inc();
        throw e;
    } finally {
        tc.stop();
    }
}
Also used : MetricManager(com.thinkaurelius.titan.util.stats.MetricManager) Timer(com.codahale.metrics.Timer)

Example 5 with MetricManager

use of com.thinkaurelius.titan.util.stats.MetricManager in project titan by thinkaurelius.

the class MetricInstrumentedStore method recordSliceMetrics.

private void recordSliceMetrics(StoreTransaction txh, List<Entry> row) {
    if (!txh.getConfiguration().hasGroupName())
        return;
    String p = txh.getConfiguration().getGroupName();
    final MetricManager mgr = MetricManager.INSTANCE;
    mgr.getCounter(p, metricsStoreName, M_GET_SLICE, M_ENTRIES_COUNT).inc(row.size());
    mgr.getHistogram(p, metricsStoreName, M_GET_SLICE, M_ENTRIES_HISTO).update(row.size());
}
Also used : MetricManager(com.thinkaurelius.titan.util.stats.MetricManager)

Aggregations

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