Refactor RocksDBStats (#1266)

Move RocksDBStats to it's own module.  This also brings metrics to
metrics:core since none of our other module have nested modules but
they have peer modules.


Signed-off-by: Adrian Sutton <adrian.sutton@consensys.net>
pull/2/head
Danno Ferrin 6 years ago committed by GitHub
parent c7947b8185
commit cf2acc2a75
  1. 2
      acceptance-tests/build.gradle
  2. 2
      consensus/clique/build.gradle
  3. 4
      consensus/ibft/build.gradle
  4. 4
      consensus/ibftlegacy/build.gradle
  5. 2
      ethereum/blockcreation/build.gradle
  6. 4
      ethereum/core/build.gradle
  7. 2
      ethereum/eth/build.gradle
  8. 2
      ethereum/jsonrpc/build.gradle
  9. 2
      ethereum/p2p/build.gradle
  10. 1
      gradle/check-licenses.gradle
  11. 35
      metrics/build.gradle
  12. 47
      metrics/core/build.gradle
  13. 0
      metrics/core/src/main/java/tech/pegasys/pantheon/metrics/Counter.java
  14. 0
      metrics/core/src/main/java/tech/pegasys/pantheon/metrics/LabelledMetric.java
  15. 0
      metrics/core/src/main/java/tech/pegasys/pantheon/metrics/MetricCategory.java
  16. 0
      metrics/core/src/main/java/tech/pegasys/pantheon/metrics/MetricsSystem.java
  17. 0
      metrics/core/src/main/java/tech/pegasys/pantheon/metrics/Observation.java
  18. 0
      metrics/core/src/main/java/tech/pegasys/pantheon/metrics/OperationTimer.java
  19. 0
      metrics/core/src/main/java/tech/pegasys/pantheon/metrics/noop/NoOpCounter.java
  20. 0
      metrics/core/src/main/java/tech/pegasys/pantheon/metrics/noop/NoOpMetricsSystem.java
  21. 0
      metrics/core/src/main/java/tech/pegasys/pantheon/metrics/prometheus/CurrentValueCollector.java
  22. 0
      metrics/core/src/main/java/tech/pegasys/pantheon/metrics/prometheus/MetricsConfiguration.java
  23. 0
      metrics/core/src/main/java/tech/pegasys/pantheon/metrics/prometheus/MetricsHttpService.java
  24. 0
      metrics/core/src/main/java/tech/pegasys/pantheon/metrics/prometheus/MetricsPushGatewayService.java
  25. 0
      metrics/core/src/main/java/tech/pegasys/pantheon/metrics/prometheus/MetricsService.java
  26. 0
      metrics/core/src/main/java/tech/pegasys/pantheon/metrics/prometheus/PrometheusCounter.java
  27. 0
      metrics/core/src/main/java/tech/pegasys/pantheon/metrics/prometheus/PrometheusMetricsSystem.java
  28. 0
      metrics/core/src/main/java/tech/pegasys/pantheon/metrics/prometheus/PrometheusTimer.java
  29. 0
      metrics/core/src/main/java/tech/pegasys/pantheon/metrics/vertx/PoolMetricsAdapter.java
  30. 0
      metrics/core/src/main/java/tech/pegasys/pantheon/metrics/vertx/VertxMetricsAdapter.java
  31. 0
      metrics/core/src/main/java/tech/pegasys/pantheon/metrics/vertx/VertxMetricsAdapterFactory.java
  32. 0
      metrics/core/src/test/java/tech/pegasys/pantheon/metrics/noop/NoOpMetricsSystemTest.java
  33. 0
      metrics/core/src/test/java/tech/pegasys/pantheon/metrics/prometheus/MetricsHttpServiceTest.java
  34. 0
      metrics/core/src/test/java/tech/pegasys/pantheon/metrics/prometheus/PrometheusMetricsSystemTest.java
  35. 37
      metrics/rocksdb/build.gradle
  36. 6
      metrics/rocksdb/src/main/java/tech/pegasys/pantheon/metrics/rocksdb/RocksDBStats.java
  37. 2
      pantheon/build.gradle
  38. 3
      services/kvstore/build.gradle
  39. 16
      services/kvstore/src/main/java/tech/pegasys/pantheon/services/kvstore/RocksDbKeyValueStorage.java
  40. 2
      services/pipeline/build.gradle
  41. 2
      services/tasks/build.gradle
  42. 2
      services/util/build.gradle
  43. 4
      settings.gradle

@ -27,7 +27,7 @@ dependencies {
testImplementation project(':ethereum:jsonrpc') testImplementation project(':ethereum:jsonrpc')
testImplementation project(':ethereum:permissioning') testImplementation project(':ethereum:permissioning')
testImplementation project(':ethereum:rlp') testImplementation project(':ethereum:rlp')
testImplementation project(':metrics') testImplementation project(':metrics:core')
testImplementation project(':pantheon') testImplementation project(':pantheon')
testImplementation project(':services:kvstore') testImplementation project(':services:kvstore')
testImplementation project(':testutil') testImplementation project(':testutil')

@ -47,7 +47,7 @@ dependencies {
testImplementation project(path: ':ethereum:core', configuration: 'testSupportArtifacts') testImplementation project(path: ':ethereum:core', configuration: 'testSupportArtifacts')
testImplementation project(path: ':consensus:common', configuration: 'testArtifacts') testImplementation project(path: ':consensus:common', configuration: 'testArtifacts')
testImplementation project(':testutil') testImplementation project(':testutil')
testImplementation project(':metrics') testImplementation project(':metrics:core')
testImplementation 'junit:junit' testImplementation 'junit:junit'
testImplementation 'org.assertj:assertj-core' testImplementation 'org.assertj:assertj-core'

@ -47,9 +47,9 @@ dependencies {
testImplementation project(path: ':config:', configuration: 'testSupportArtifacts') testImplementation project(path: ':config:', configuration: 'testSupportArtifacts')
testImplementation project(path: ':consensus:common', configuration: 'testArtifacts') testImplementation project(path: ':consensus:common', configuration: 'testArtifacts')
testImplementation project(':testutil') testImplementation project(':testutil')
testImplementation project(':metrics') testImplementation project(':metrics:core')
integrationTestImplementation project(':metrics') integrationTestImplementation project(':metrics:core')
integrationTestImplementation 'junit:junit' integrationTestImplementation 'junit:junit'
integrationTestImplementation 'org.assertj:assertj-core' integrationTestImplementation 'org.assertj:assertj-core'
integrationTestImplementation 'org.mockito:mockito-core' integrationTestImplementation 'org.mockito:mockito-core'

@ -23,7 +23,7 @@ dependencies {
implementation project(':ethereum:jsonrpc') implementation project(':ethereum:jsonrpc')
implementation project(':ethereum:rlp') implementation project(':ethereum:rlp')
implementation project(':ethereum:p2p') implementation project(':ethereum:p2p')
implementation project(':metrics') implementation project(':metrics:core')
implementation project(':services:kvstore') implementation project(':services:kvstore')
implementation 'com.google.guava:guava' implementation 'com.google.guava:guava'
@ -32,7 +32,7 @@ dependencies {
testImplementation project(path: ':ethereum:core', configuration: 'testSupportArtifacts') testImplementation project(path: ':ethereum:core', configuration: 'testSupportArtifacts')
testImplementation project(path: ':consensus:ibft', configuration: 'testSupportArtifacts') testImplementation project(path: ':consensus:ibft', configuration: 'testSupportArtifacts')
testImplementation project(':testutil') testImplementation project(':testutil')
testImplementation project(':metrics') testImplementation project(':metrics:core')
testImplementation 'junit:junit' testImplementation 'junit:junit'
testImplementation 'org.assertj:assertj-core' testImplementation 'org.assertj:assertj-core'

@ -27,7 +27,7 @@ dependencies {
testImplementation project(path: ':ethereum:core', configuration: 'testSupportArtifacts') testImplementation project(path: ':ethereum:core', configuration: 'testSupportArtifacts')
testImplementation project(path: ':ethereum:core', configuration: 'testArtifacts') testImplementation project(path: ':ethereum:core', configuration: 'testArtifacts')
testImplementation project(':testutil') testImplementation project(':testutil')
testImplementation project(':metrics') testImplementation project(':metrics:core')
testImplementation 'junit:junit' testImplementation 'junit:junit'
testImplementation 'org.assertj:assertj-core' testImplementation 'org.assertj:assertj-core'
testImplementation 'org.awaitility:awaitility' testImplementation 'org.awaitility:awaitility'

@ -31,7 +31,7 @@ dependencies {
implementation project(':enclave') implementation project(':enclave')
implementation project(':ethereum:rlp') implementation project(':ethereum:rlp')
implementation project(':ethereum:trie') implementation project(':ethereum:trie')
implementation project(':metrics') implementation project(':metrics:core')
implementation project(':services:kvstore') implementation project(':services:kvstore')
implementation 'com.fasterxml.jackson.core:jackson-databind' implementation 'com.fasterxml.jackson.core:jackson-databind'
@ -71,7 +71,7 @@ dependencies {
jmhImplementation project(path: ':ethereum:core', configuration: 'testSupportArtifacts') jmhImplementation project(path: ':ethereum:core', configuration: 'testSupportArtifacts')
jmhImplementation project(':ethereum:rlp') jmhImplementation project(':ethereum:rlp')
jmhImplementation project(':ethereum:trie') jmhImplementation project(':ethereum:trie')
jmhImplementation project(':metrics') jmhImplementation project(':metrics:core')
jmhImplementation project(':services:kvstore') jmhImplementation project(':services:kvstore')
jmhImplementation project(':util') jmhImplementation project(':util')

@ -31,7 +31,7 @@ dependencies {
implementation project(':ethereum:rlp') implementation project(':ethereum:rlp')
implementation project(':ethereum:trie') implementation project(':ethereum:trie')
implementation project(':ethereum:permissioning') implementation project(':ethereum:permissioning')
implementation project(':metrics') implementation project(':metrics:core')
implementation project(':services:kvstore') implementation project(':services:kvstore')
implementation project(':services:pipeline') implementation project(':services:pipeline')
implementation project(':services:tasks') implementation project(':services:tasks')

@ -35,7 +35,7 @@ dependencies {
implementation project(':ethereum:p2p') implementation project(':ethereum:p2p')
implementation project(':ethereum:rlp') implementation project(':ethereum:rlp')
implementation project(':ethereum:permissioning') implementation project(':ethereum:permissioning')
implementation project(':metrics') implementation project(':metrics:core')
implementation 'com.google.guava:guava' implementation 'com.google.guava:guava'
implementation 'io.vertx:vertx-core' implementation 'io.vertx:vertx-core'

@ -30,7 +30,7 @@ dependencies {
implementation project(':ethereum:core') implementation project(':ethereum:core')
implementation project(':ethereum:permissioning') implementation project(':ethereum:permissioning')
implementation project(':ethereum:rlp') implementation project(':ethereum:rlp')
implementation project(':metrics') implementation project(':metrics:core')
implementation 'com.google.guava:guava' implementation 'com.google.guava:guava'
implementation 'io.prometheus:simpleclient' implementation 'io.prometheus:simpleclient'

@ -127,6 +127,7 @@ downloadLicenses {
(group('pantheon.ethereum')) : apache, (group('pantheon.ethereum')) : apache,
(group('pantheon.services')) : apache, (group('pantheon.services')) : apache,
(group('pantheon.consensus')) : apache, (group('pantheon.consensus')) : apache,
(group('pantheon.metrics')) : apache,
// https://checkerframework.org/manual/#license // https://checkerframework.org/manual/#license
// The more permissive MIT License applies to code that you might want // The more permissive MIT License applies to code that you might want

@ -11,37 +11,4 @@
* specific language governing permissions and limitations under the License. * specific language governing permissions and limitations under the License.
*/ */
apply plugin: 'java-library' jar { enabled = false }
jar {
baseName 'pantheon-metrics'
manifest {
attributes(
'Specification-Title': baseName,
'Specification-Version': project.version,
'Implementation-Title': baseName,
'Implementation-Version': calculateVersion()
)
}
}
dependencies {
implementation project(':util')
implementation 'com.google.guava:guava'
implementation 'io.prometheus:simpleclient'
implementation 'io.prometheus:simpleclient_common'
implementation 'io.prometheus:simpleclient_hotspot'
implementation 'io.prometheus:simpleclient_pushgateway'
implementation 'io.vertx:vertx-core'
implementation 'io.vertx:vertx-web'
implementation 'org.apache.logging.log4j:log4j-api'
runtime 'org.apache.logging.log4j:log4j-core'
// test dependencies.
testImplementation 'junit:junit'
testImplementation 'org.assertj:assertj-core'
testImplementation 'org.mockito:mockito-core'
testImplementation 'com.squareup.okhttp3:okhttp'
}

@ -0,0 +1,47 @@
/*
* Copyright 2018 ConsenSys AG.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
apply plugin: 'java-library'
jar {
baseName 'pantheon-metrics-core'
manifest {
attributes(
'Specification-Title': baseName,
'Specification-Version': project.version,
'Implementation-Title': baseName,
'Implementation-Version': calculateVersion()
)
}
}
dependencies {
implementation project(':util')
implementation 'com.google.guava:guava'
implementation 'io.prometheus:simpleclient'
implementation 'io.prometheus:simpleclient_common'
implementation 'io.prometheus:simpleclient_hotspot'
implementation 'io.prometheus:simpleclient_pushgateway'
implementation 'io.vertx:vertx-core'
implementation 'io.vertx:vertx-web'
implementation 'org.apache.logging.log4j:log4j-api'
runtime 'org.apache.logging.log4j:log4j-core'
// test dependencies.
testImplementation 'junit:junit'
testImplementation 'org.assertj:assertj-core'
testImplementation 'org.mockito:mockito-core'
testImplementation 'com.squareup.okhttp3:okhttp'
}

@ -0,0 +1,37 @@
/*
* Copyright 2018 ConsenSys AG.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
apply plugin: 'java-library'
jar {
baseName 'pantheon-metrics-rocksdb'
manifest {
attributes(
'Specification-Title': baseName,
'Specification-Version': project.version,
'Implementation-Title': baseName,
'Implementation-Version': calculateVersion()
)
}
}
dependencies {
implementation project(':metrics:core')
implementation project(':services:util')
implementation 'com.google.guava:guava'
implementation 'io.prometheus:simpleclient'
implementation 'info.picocli:picocli'
implementation 'org.apache.logging.log4j:log4j-api'
implementation 'org.rocksdb:rocksdbjni'
}

@ -10,7 +10,7 @@
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License. * specific language governing permissions and limitations under the License.
*/ */
package tech.pegasys.pantheon.services.kvstore; package tech.pegasys.pantheon.metrics.rocksdb;
import static tech.pegasys.pantheon.metrics.MetricCategory.KVSTORE_ROCKSDB_STATS; import static tech.pegasys.pantheon.metrics.MetricCategory.KVSTORE_ROCKSDB_STATS;
@ -26,7 +26,7 @@ import org.rocksdb.HistogramType;
import org.rocksdb.Statistics; import org.rocksdb.Statistics;
import org.rocksdb.TickerType; import org.rocksdb.TickerType;
class RocksDBStats { public class RocksDBStats {
static final List<String> LABELS = Collections.singletonList("quantile"); static final List<String> LABELS = Collections.singletonList("quantile");
static final List<String> LABEL_50 = Collections.singletonList("0.5"); static final List<String> LABEL_50 = Collections.singletonList("0.5");
@ -166,7 +166,7 @@ class RocksDBStats {
HistogramType.READ_NUM_MERGE_OPERANDS, HistogramType.READ_NUM_MERGE_OPERANDS,
}; };
static void registerRocksDBMetrics( public static void registerRocksDBMetrics(
final Statistics stats, final PrometheusMetricsSystem metricsSystem) { final Statistics stats, final PrometheusMetricsSystem metricsSystem) {
for (final TickerType ticker : TICKERS) { for (final TickerType ticker : TICKERS) {

@ -39,7 +39,7 @@ dependencies {
implementation project(':ethereum:permissioning') implementation project(':ethereum:permissioning')
implementation project(':ethereum:p2p') implementation project(':ethereum:p2p')
implementation project(':ethereum:rlp') implementation project(':ethereum:rlp')
implementation project(':metrics') implementation project(':metrics:core')
implementation project(':enclave') implementation project(':enclave')
implementation project(':services:kvstore') implementation project(':services:kvstore')

@ -28,7 +28,8 @@ jar {
dependencies { dependencies {
api project(':util') api project(':util')
implementation project(':metrics') implementation project(':metrics:core')
implementation project(':metrics:rocksdb')
implementation project(':services:util') implementation project(':services:util')
implementation 'com.google.guava:guava' implementation 'com.google.guava:guava'

@ -16,6 +16,8 @@ import tech.pegasys.pantheon.metrics.Counter;
import tech.pegasys.pantheon.metrics.MetricCategory; import tech.pegasys.pantheon.metrics.MetricCategory;
import tech.pegasys.pantheon.metrics.MetricsSystem; import tech.pegasys.pantheon.metrics.MetricsSystem;
import tech.pegasys.pantheon.metrics.OperationTimer; import tech.pegasys.pantheon.metrics.OperationTimer;
import tech.pegasys.pantheon.metrics.prometheus.PrometheusMetricsSystem;
import tech.pegasys.pantheon.metrics.rocksdb.RocksDBStats;
import tech.pegasys.pantheon.services.util.RocksDbUtil; import tech.pegasys.pantheon.services.util.RocksDbUtil;
import tech.pegasys.pantheon.util.bytes.BytesValue; import tech.pegasys.pantheon.util.bytes.BytesValue;
@ -75,7 +77,7 @@ public class RocksDbKeyValueStorage implements KeyValueStorage, Closeable {
MetricCategory.KVSTORE_ROCKSDB, MetricCategory.KVSTORE_ROCKSDB,
"read_latency_seconds", "read_latency_seconds",
"Latency for read from RocksDB.", "Latency for read from RocksDB.",
rocksDbConfiguration.getLabel()) "database")
.labels(rocksDbConfiguration.getLabel()); .labels(rocksDbConfiguration.getLabel());
removeLatency = removeLatency =
metricsSystem metricsSystem
@ -83,7 +85,7 @@ public class RocksDbKeyValueStorage implements KeyValueStorage, Closeable {
MetricCategory.KVSTORE_ROCKSDB, MetricCategory.KVSTORE_ROCKSDB,
"remove_latency_seconds", "remove_latency_seconds",
"Latency of remove requests from RocksDB.", "Latency of remove requests from RocksDB.",
rocksDbConfiguration.getLabel()) "database")
.labels(rocksDbConfiguration.getLabel()); .labels(rocksDbConfiguration.getLabel());
writeLatency = writeLatency =
metricsSystem metricsSystem
@ -91,7 +93,7 @@ public class RocksDbKeyValueStorage implements KeyValueStorage, Closeable {
MetricCategory.KVSTORE_ROCKSDB, MetricCategory.KVSTORE_ROCKSDB,
"write_latency_seconds", "write_latency_seconds",
"Latency for write to RocksDB.", "Latency for write to RocksDB.",
rocksDbConfiguration.getLabel()) "database")
.labels(rocksDbConfiguration.getLabel()); .labels(rocksDbConfiguration.getLabel());
commitLatency = commitLatency =
metricsSystem metricsSystem
@ -99,9 +101,13 @@ public class RocksDbKeyValueStorage implements KeyValueStorage, Closeable {
MetricCategory.KVSTORE_ROCKSDB, MetricCategory.KVSTORE_ROCKSDB,
"commit_latency_seconds", "commit_latency_seconds",
"Latency for commits to RocksDB.", "Latency for commits to RocksDB.",
rocksDbConfiguration.getLabel()) "database")
.labels(rocksDbConfiguration.getLabel()); .labels(rocksDbConfiguration.getLabel());
if (metricsSystem instanceof PrometheusMetricsSystem) {
RocksDBStats.registerRocksDBMetrics(stats, (PrometheusMetricsSystem) metricsSystem);
}
metricsSystem.createLongGauge( metricsSystem.createLongGauge(
MetricCategory.KVSTORE_ROCKSDB, MetricCategory.KVSTORE_ROCKSDB,
"rocks_db_table_readers_memory_bytes", "rocks_db_table_readers_memory_bytes",
@ -121,7 +127,7 @@ public class RocksDbKeyValueStorage implements KeyValueStorage, Closeable {
MetricCategory.KVSTORE_ROCKSDB, MetricCategory.KVSTORE_ROCKSDB,
"rollback_count", "rollback_count",
"Number of RocksDB transactions rolled back.", "Number of RocksDB transactions rolled back.",
rocksDbConfiguration.getLabel()) "database")
.labels(rocksDbConfiguration.getLabel()); .labels(rocksDbConfiguration.getLabel());
} catch (final RocksDBException e) { } catch (final RocksDBException e) {
throw new StorageException(e); throw new StorageException(e);

@ -27,7 +27,7 @@ jar {
dependencies { dependencies {
api project(':util') api project(':util')
implementation project(':metrics') implementation project(':metrics:core')
implementation 'org.apache.logging.log4j:log4j-api' implementation 'org.apache.logging.log4j:log4j-api'
implementation 'com.google.guava:guava' implementation 'com.google.guava:guava'

@ -30,7 +30,7 @@ dependencies {
compileOnly 'org.openjdk.jmh:jmh-generator-annprocess' compileOnly 'org.openjdk.jmh:jmh-generator-annprocess'
implementation project(':metrics') implementation project(':metrics:core')
implementation project(':services:util') implementation project(':services:util')
implementation 'org.apache.logging.log4j:log4j-api' implementation 'org.apache.logging.log4j:log4j-api'

@ -27,7 +27,7 @@ jar {
dependencies { dependencies {
api project(':util') api project(':util')
implementation project(':metrics') implementation project(':metrics:core')
implementation 'org.apache.logging.log4j:log4j-api' implementation 'org.apache.logging.log4j:log4j-api'
implementation 'com.google.guava:guava' implementation 'com.google.guava:guava'

@ -14,7 +14,6 @@
rootProject.name='pantheon' rootProject.name='pantheon'
include 'acceptance-tests' include 'acceptance-tests'
include 'config' include 'config'
include 'consensus'
include 'consensus:clique' include 'consensus:clique'
include 'consensus:common' include 'consensus:common'
include 'consensus:ibft' include 'consensus:ibft'
@ -32,7 +31,8 @@ include 'ethereum:permissioning'
include 'ethereum:referencetests' include 'ethereum:referencetests'
include 'ethereum:rlp' include 'ethereum:rlp'
include 'ethereum:trie' include 'ethereum:trie'
include 'metrics' include 'metrics:core'
include 'metrics:rocksdb'
include 'pantheon' include 'pantheon'
include 'services:kvstore' include 'services:kvstore'
include 'services:pipeline' include 'services:pipeline'

Loading…
Cancel
Save