[PRIV-46] Use labelled timer to differentiate between rocks db metrics (#1254)

* Use labelled timer to differentiate between metrics of public and private db

* Update the label names

Signed-off-by: Adrian Sutton <adrian.sutton@consensys.net>
pull/2/head
Puneetha Karamsetty 6 years ago committed by Danno Ferrin
parent 9e34ae649f
commit 545578983b
  1. 5
      ethereum/core/src/main/java/tech/pegasys/pantheon/ethereum/core/PrivacyParameters.java
  2. 16
      services/kvstore/src/main/java/tech/pegasys/pantheon/services/kvstore/RocksDbConfiguration.java
  3. 60
      services/kvstore/src/main/java/tech/pegasys/pantheon/services/kvstore/RocksDbKeyValueStorage.java

@ -176,7 +176,10 @@ public class PrivacyParameters {
Path privateDbPath = dataDir.resolve(PRIVATE_DATABASE_PATH);
StorageProvider privateStorageProvider =
RocksDbStorageProvider.create(
new RocksDbConfiguration.Builder().databaseDir(privateDbPath).build(),
new RocksDbConfiguration.Builder()
.databaseDir(privateDbPath)
.label("private_state")
.build(),
metricsSystem);
WorldStateStorage privateWorldStateStorage =
privateStorageProvider.createWorldStateStorage();

@ -25,13 +25,15 @@ public class RocksDbConfiguration {
private final Path databaseDir;
private final int maxOpenFiles;
private final BlockBasedTableConfig blockBasedTableConfig;
private final String label;
public RocksDbConfiguration(
final Path databaseDir, final int maxOpenFiles, final LRUCache cache) {
final Path databaseDir, final int maxOpenFiles, final LRUCache cache, final String label) {
RocksDbUtil.loadNativeLibrary();
this.databaseDir = databaseDir;
this.maxOpenFiles = maxOpenFiles;
this.blockBasedTableConfig = new BlockBasedTableConfig().setBlockCache(cache);
this.label = label;
}
public Path getDatabaseDir() {
@ -46,10 +48,15 @@ public class RocksDbConfiguration {
return blockBasedTableConfig;
}
public String getLabel() {
return label;
}
public static class Builder {
Path databaseDir;
LRUCache cache = null;
String label = "blockchain";
@CommandLine.Option(
names = {"--Xrocksdb-max-open-files"},
@ -77,6 +84,11 @@ public class RocksDbConfiguration {
return this;
}
public Builder label(final String label) {
this.label = label;
return this;
}
public Builder cacheCapacity(final long cacheCapacity) {
this.cacheCapacity = cacheCapacity;
return this;
@ -91,7 +103,7 @@ public class RocksDbConfiguration {
if (cache == null) {
cache = createCache(cacheCapacity);
}
return new RocksDbConfiguration(databaseDir, maxOpenFiles, cache);
return new RocksDbConfiguration(databaseDir, maxOpenFiles, cache, label);
}
}
}

@ -16,7 +16,6 @@ import tech.pegasys.pantheon.metrics.Counter;
import tech.pegasys.pantheon.metrics.MetricCategory;
import tech.pegasys.pantheon.metrics.MetricsSystem;
import tech.pegasys.pantheon.metrics.OperationTimer;
import tech.pegasys.pantheon.metrics.prometheus.PrometheusMetricsSystem;
import tech.pegasys.pantheon.services.util.RocksDbUtil;
import tech.pegasys.pantheon.util.bytes.BytesValue;
@ -71,29 +70,37 @@ public class RocksDbKeyValueStorage implements KeyValueStorage, Closeable {
db = TransactionDB.open(options, txOptions, rocksDbConfiguration.getDatabaseDir().toString());
readLatency =
metricsSystem.createTimer(
MetricCategory.KVSTORE_ROCKSDB,
"read_latency_seconds",
"Latency for read from RocksDB.");
metricsSystem
.createLabelledTimer(
MetricCategory.KVSTORE_ROCKSDB,
"read_latency_seconds",
"Latency for read from RocksDB.",
rocksDbConfiguration.getLabel())
.labels(rocksDbConfiguration.getLabel());
removeLatency =
metricsSystem.createTimer(
MetricCategory.KVSTORE_ROCKSDB,
"remove_latency_seconds",
"Latency of remove requests from RocksDB.");
metricsSystem
.createLabelledTimer(
MetricCategory.KVSTORE_ROCKSDB,
"remove_latency_seconds",
"Latency of remove requests from RocksDB.",
rocksDbConfiguration.getLabel())
.labels(rocksDbConfiguration.getLabel());
writeLatency =
metricsSystem.createTimer(
MetricCategory.KVSTORE_ROCKSDB,
"write_latency_seconds",
"Latency for write to RocksDB.");
metricsSystem
.createLabelledTimer(
MetricCategory.KVSTORE_ROCKSDB,
"write_latency_seconds",
"Latency for write to RocksDB.",
rocksDbConfiguration.getLabel())
.labels(rocksDbConfiguration.getLabel());
commitLatency =
metricsSystem.createTimer(
MetricCategory.KVSTORE_ROCKSDB,
"commit_latency_seconds",
"Latency for commits to RocksDB.");
if (metricsSystem instanceof PrometheusMetricsSystem) {
RocksDBStats.registerRocksDBMetrics(stats, (PrometheusMetricsSystem) metricsSystem);
}
metricsSystem
.createLabelledTimer(
MetricCategory.KVSTORE_ROCKSDB,
"commit_latency_seconds",
"Latency for commits to RocksDB.",
rocksDbConfiguration.getLabel())
.labels(rocksDbConfiguration.getLabel());
metricsSystem.createLongGauge(
MetricCategory.KVSTORE_ROCKSDB,
@ -109,10 +116,13 @@ public class RocksDbKeyValueStorage implements KeyValueStorage, Closeable {
});
rollbackCount =
metricsSystem.createCounter(
MetricCategory.KVSTORE_ROCKSDB,
"rollback_count",
"Number of RocksDB transactions rolled back.");
metricsSystem
.createLabelledCounter(
MetricCategory.KVSTORE_ROCKSDB,
"rollback_count",
"Number of RocksDB transactions rolled back.",
rocksDbConfiguration.getLabel())
.labels(rocksDbConfiguration.getLabel());
} catch (final RocksDBException e) {
throw new StorageException(e);
}

Loading…
Cancel
Save