Search in sources :

Example 1 with MetricManager

use of org.janusgraph.util.stats.MetricManager in project janusgraph by JanusGraph.

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 | RuntimeException e) {
        mgr.getCounter(prefix, storeName, name, M_EXCEPTIONS).inc();
        throw e;
    } finally {
        tc.stop();
    }
}
Also used : MetricManager(org.janusgraph.util.stats.MetricManager) Timer(com.codahale.metrics.Timer) BackendException(org.janusgraph.diskstorage.BackendException)

Example 2 with MetricManager

use of org.janusgraph.util.stats.MetricManager in project janusgraph by JanusGraph.

the class MetricInstrumentedStore method runWithMetrics.

static <T> T runWithMetrics(String prefix, 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, null, name, M_CALLS).inc();
    final Timer.Context tc = mgr.getTimer(prefix, null, name, M_TIME).time();
    try {
        return impl.call();
    } catch (RuntimeException e) {
        mgr.getCounter(prefix, null, name, M_EXCEPTIONS).inc();
        throw e;
    } finally {
        tc.stop();
    }
}
Also used : MetricManager(org.janusgraph.util.stats.MetricManager) Timer(com.codahale.metrics.Timer)

Example 3 with MetricManager

use of org.janusgraph.util.stats.MetricManager in project janusgraph by JanusGraph.

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 | RuntimeException e) {
        mgr.getCounter(prefix, managerMetricsName, M_MUTATE, M_EXCEPTIONS).inc();
        throw e;
    } finally {
        tc.stop();
    }
}
Also used : MetricManager(org.janusgraph.util.stats.MetricManager) Timer(com.codahale.metrics.Timer) BackendException(org.janusgraph.diskstorage.BackendException)

Example 4 with MetricManager

use of org.janusgraph.util.stats.MetricManager in project janusgraph by JanusGraph.

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();
    try (final Timer.Context tc = mgr.getTimer(metricsPrefix, opName, M_TIME).time()) {
        return impl.apply(null);
    } catch (RuntimeException e) {
        mgr.getCounter(metricsPrefix, opName, M_EXCEPTIONS).inc();
        throw e;
    }
}
Also used : MetricManager(org.janusgraph.util.stats.MetricManager) Timer(com.codahale.metrics.Timer)

Example 5 with MetricManager

use of org.janusgraph.util.stats.MetricManager in project janusgraph by JanusGraph.

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(org.janusgraph.util.stats.MetricManager)

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