From cf2acc2a75191516efdde835958d25bf1c218843 Mon Sep 17 00:00:00 2001 From: Danno Ferrin Date: Fri, 12 Apr 2019 21:15:33 -0600 Subject: [PATCH] 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 --- acceptance-tests/build.gradle | 2 +- consensus/clique/build.gradle | 2 +- consensus/ibft/build.gradle | 4 +- consensus/ibftlegacy/build.gradle | 4 +- ethereum/blockcreation/build.gradle | 2 +- ethereum/core/build.gradle | 4 +- ethereum/eth/build.gradle | 2 +- ethereum/jsonrpc/build.gradle | 2 +- ethereum/p2p/build.gradle | 2 +- gradle/check-licenses.gradle | 1 + metrics/build.gradle | 35 +------------- metrics/core/build.gradle | 47 +++++++++++++++++++ .../pegasys/pantheon/metrics/Counter.java | 0 .../pantheon/metrics/LabelledMetric.java | 0 .../pantheon/metrics/MetricCategory.java | 0 .../pantheon/metrics/MetricsSystem.java | 0 .../pegasys/pantheon/metrics/Observation.java | 0 .../pantheon/metrics/OperationTimer.java | 0 .../pantheon/metrics/noop/NoOpCounter.java | 0 .../metrics/noop/NoOpMetricsSystem.java | 0 .../prometheus/CurrentValueCollector.java | 0 .../prometheus/MetricsConfiguration.java | 0 .../prometheus/MetricsHttpService.java | 0 .../prometheus/MetricsPushGatewayService.java | 0 .../metrics/prometheus/MetricsService.java | 0 .../metrics/prometheus/PrometheusCounter.java | 0 .../prometheus/PrometheusMetricsSystem.java | 0 .../metrics/prometheus/PrometheusTimer.java | 0 .../metrics/vertx/PoolMetricsAdapter.java | 0 .../metrics/vertx/VertxMetricsAdapter.java | 0 .../vertx/VertxMetricsAdapterFactory.java | 0 .../metrics/noop/NoOpMetricsSystemTest.java | 0 .../prometheus/MetricsHttpServiceTest.java | 0 .../PrometheusMetricsSystemTest.java | 0 metrics/rocksdb/build.gradle | 37 +++++++++++++++ .../metrics/rocksdb}/RocksDBStats.java | 6 +-- pantheon/build.gradle | 2 +- services/kvstore/build.gradle | 3 +- .../kvstore/RocksDbKeyValueStorage.java | 16 +++++-- services/pipeline/build.gradle | 2 +- services/tasks/build.gradle | 2 +- services/util/build.gradle | 2 +- settings.gradle | 4 +- 43 files changed, 120 insertions(+), 61 deletions(-) create mode 100644 metrics/core/build.gradle rename metrics/{ => core}/src/main/java/tech/pegasys/pantheon/metrics/Counter.java (100%) rename metrics/{ => core}/src/main/java/tech/pegasys/pantheon/metrics/LabelledMetric.java (100%) rename metrics/{ => core}/src/main/java/tech/pegasys/pantheon/metrics/MetricCategory.java (100%) rename metrics/{ => core}/src/main/java/tech/pegasys/pantheon/metrics/MetricsSystem.java (100%) rename metrics/{ => core}/src/main/java/tech/pegasys/pantheon/metrics/Observation.java (100%) rename metrics/{ => core}/src/main/java/tech/pegasys/pantheon/metrics/OperationTimer.java (100%) rename metrics/{ => core}/src/main/java/tech/pegasys/pantheon/metrics/noop/NoOpCounter.java (100%) rename metrics/{ => core}/src/main/java/tech/pegasys/pantheon/metrics/noop/NoOpMetricsSystem.java (100%) rename metrics/{ => core}/src/main/java/tech/pegasys/pantheon/metrics/prometheus/CurrentValueCollector.java (100%) rename metrics/{ => core}/src/main/java/tech/pegasys/pantheon/metrics/prometheus/MetricsConfiguration.java (100%) rename metrics/{ => core}/src/main/java/tech/pegasys/pantheon/metrics/prometheus/MetricsHttpService.java (100%) rename metrics/{ => core}/src/main/java/tech/pegasys/pantheon/metrics/prometheus/MetricsPushGatewayService.java (100%) rename metrics/{ => core}/src/main/java/tech/pegasys/pantheon/metrics/prometheus/MetricsService.java (100%) rename metrics/{ => core}/src/main/java/tech/pegasys/pantheon/metrics/prometheus/PrometheusCounter.java (100%) rename metrics/{ => core}/src/main/java/tech/pegasys/pantheon/metrics/prometheus/PrometheusMetricsSystem.java (100%) rename metrics/{ => core}/src/main/java/tech/pegasys/pantheon/metrics/prometheus/PrometheusTimer.java (100%) rename metrics/{ => core}/src/main/java/tech/pegasys/pantheon/metrics/vertx/PoolMetricsAdapter.java (100%) rename metrics/{ => core}/src/main/java/tech/pegasys/pantheon/metrics/vertx/VertxMetricsAdapter.java (100%) rename metrics/{ => core}/src/main/java/tech/pegasys/pantheon/metrics/vertx/VertxMetricsAdapterFactory.java (100%) rename metrics/{ => core}/src/test/java/tech/pegasys/pantheon/metrics/noop/NoOpMetricsSystemTest.java (100%) rename metrics/{ => core}/src/test/java/tech/pegasys/pantheon/metrics/prometheus/MetricsHttpServiceTest.java (100%) rename metrics/{ => core}/src/test/java/tech/pegasys/pantheon/metrics/prometheus/PrometheusMetricsSystemTest.java (100%) create mode 100644 metrics/rocksdb/build.gradle rename {services/kvstore/src/main/java/tech/pegasys/pantheon/services/kvstore => metrics/rocksdb/src/main/java/tech/pegasys/pantheon/metrics/rocksdb}/RocksDBStats.java (98%) diff --git a/acceptance-tests/build.gradle b/acceptance-tests/build.gradle index 177381f15a..3fe6f33d83 100644 --- a/acceptance-tests/build.gradle +++ b/acceptance-tests/build.gradle @@ -27,7 +27,7 @@ dependencies { testImplementation project(':ethereum:jsonrpc') testImplementation project(':ethereum:permissioning') testImplementation project(':ethereum:rlp') - testImplementation project(':metrics') + testImplementation project(':metrics:core') testImplementation project(':pantheon') testImplementation project(':services:kvstore') testImplementation project(':testutil') diff --git a/consensus/clique/build.gradle b/consensus/clique/build.gradle index 6fd9c2c209..34d1da47a7 100644 --- a/consensus/clique/build.gradle +++ b/consensus/clique/build.gradle @@ -47,7 +47,7 @@ dependencies { testImplementation project(path: ':ethereum:core', configuration: 'testSupportArtifacts') testImplementation project(path: ':consensus:common', configuration: 'testArtifacts') testImplementation project(':testutil') - testImplementation project(':metrics') + testImplementation project(':metrics:core') testImplementation 'junit:junit' testImplementation 'org.assertj:assertj-core' diff --git a/consensus/ibft/build.gradle b/consensus/ibft/build.gradle index 34c1e19027..8378808a13 100644 --- a/consensus/ibft/build.gradle +++ b/consensus/ibft/build.gradle @@ -47,9 +47,9 @@ dependencies { testImplementation project(path: ':config:', configuration: 'testSupportArtifacts') testImplementation project(path: ':consensus:common', configuration: 'testArtifacts') testImplementation project(':testutil') - testImplementation project(':metrics') + testImplementation project(':metrics:core') - integrationTestImplementation project(':metrics') + integrationTestImplementation project(':metrics:core') integrationTestImplementation 'junit:junit' integrationTestImplementation 'org.assertj:assertj-core' integrationTestImplementation 'org.mockito:mockito-core' diff --git a/consensus/ibftlegacy/build.gradle b/consensus/ibftlegacy/build.gradle index ad7ac76e33..15b840d26a 100644 --- a/consensus/ibftlegacy/build.gradle +++ b/consensus/ibftlegacy/build.gradle @@ -23,7 +23,7 @@ dependencies { implementation project(':ethereum:jsonrpc') implementation project(':ethereum:rlp') implementation project(':ethereum:p2p') - implementation project(':metrics') + implementation project(':metrics:core') implementation project(':services:kvstore') implementation 'com.google.guava:guava' @@ -32,7 +32,7 @@ dependencies { testImplementation project(path: ':ethereum:core', configuration: 'testSupportArtifacts') testImplementation project(path: ':consensus:ibft', configuration: 'testSupportArtifacts') testImplementation project(':testutil') - testImplementation project(':metrics') + testImplementation project(':metrics:core') testImplementation 'junit:junit' testImplementation 'org.assertj:assertj-core' diff --git a/ethereum/blockcreation/build.gradle b/ethereum/blockcreation/build.gradle index 3ea5ee1b89..92352e0a04 100644 --- a/ethereum/blockcreation/build.gradle +++ b/ethereum/blockcreation/build.gradle @@ -27,7 +27,7 @@ dependencies { testImplementation project(path: ':ethereum:core', configuration: 'testSupportArtifacts') testImplementation project(path: ':ethereum:core', configuration: 'testArtifacts') testImplementation project(':testutil') - testImplementation project(':metrics') + testImplementation project(':metrics:core') testImplementation 'junit:junit' testImplementation 'org.assertj:assertj-core' testImplementation 'org.awaitility:awaitility' diff --git a/ethereum/core/build.gradle b/ethereum/core/build.gradle index de6349b11e..62a6ef901d 100644 --- a/ethereum/core/build.gradle +++ b/ethereum/core/build.gradle @@ -31,7 +31,7 @@ dependencies { implementation project(':enclave') implementation project(':ethereum:rlp') implementation project(':ethereum:trie') - implementation project(':metrics') + implementation project(':metrics:core') implementation project(':services:kvstore') implementation 'com.fasterxml.jackson.core:jackson-databind' @@ -71,7 +71,7 @@ dependencies { jmhImplementation project(path: ':ethereum:core', configuration: 'testSupportArtifacts') jmhImplementation project(':ethereum:rlp') jmhImplementation project(':ethereum:trie') - jmhImplementation project(':metrics') + jmhImplementation project(':metrics:core') jmhImplementation project(':services:kvstore') jmhImplementation project(':util') diff --git a/ethereum/eth/build.gradle b/ethereum/eth/build.gradle index 0edc1cbb75..a89993fee2 100644 --- a/ethereum/eth/build.gradle +++ b/ethereum/eth/build.gradle @@ -31,7 +31,7 @@ dependencies { implementation project(':ethereum:rlp') implementation project(':ethereum:trie') implementation project(':ethereum:permissioning') - implementation project(':metrics') + implementation project(':metrics:core') implementation project(':services:kvstore') implementation project(':services:pipeline') implementation project(':services:tasks') diff --git a/ethereum/jsonrpc/build.gradle b/ethereum/jsonrpc/build.gradle index 1f11be08d2..b22d6bca1d 100644 --- a/ethereum/jsonrpc/build.gradle +++ b/ethereum/jsonrpc/build.gradle @@ -35,7 +35,7 @@ dependencies { implementation project(':ethereum:p2p') implementation project(':ethereum:rlp') implementation project(':ethereum:permissioning') - implementation project(':metrics') + implementation project(':metrics:core') implementation 'com.google.guava:guava' implementation 'io.vertx:vertx-core' diff --git a/ethereum/p2p/build.gradle b/ethereum/p2p/build.gradle index 2503f084c9..910761cf7e 100644 --- a/ethereum/p2p/build.gradle +++ b/ethereum/p2p/build.gradle @@ -30,7 +30,7 @@ dependencies { implementation project(':ethereum:core') implementation project(':ethereum:permissioning') implementation project(':ethereum:rlp') - implementation project(':metrics') + implementation project(':metrics:core') implementation 'com.google.guava:guava' implementation 'io.prometheus:simpleclient' diff --git a/gradle/check-licenses.gradle b/gradle/check-licenses.gradle index e14cfd232b..e969e742d2 100644 --- a/gradle/check-licenses.gradle +++ b/gradle/check-licenses.gradle @@ -127,6 +127,7 @@ downloadLicenses { (group('pantheon.ethereum')) : apache, (group('pantheon.services')) : apache, (group('pantheon.consensus')) : apache, + (group('pantheon.metrics')) : apache, // https://checkerframework.org/manual/#license // The more permissive MIT License applies to code that you might want diff --git a/metrics/build.gradle b/metrics/build.gradle index 222f6dadb4..e7af72ad80 100644 --- a/metrics/build.gradle +++ b/metrics/build.gradle @@ -11,37 +11,4 @@ * specific language governing permissions and limitations under the License. */ -apply plugin: 'java-library' - -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' -} +jar { enabled = false } diff --git a/metrics/core/build.gradle b/metrics/core/build.gradle new file mode 100644 index 0000000000..f919d0cc37 --- /dev/null +++ b/metrics/core/build.gradle @@ -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' +} diff --git a/metrics/src/main/java/tech/pegasys/pantheon/metrics/Counter.java b/metrics/core/src/main/java/tech/pegasys/pantheon/metrics/Counter.java similarity index 100% rename from metrics/src/main/java/tech/pegasys/pantheon/metrics/Counter.java rename to metrics/core/src/main/java/tech/pegasys/pantheon/metrics/Counter.java diff --git a/metrics/src/main/java/tech/pegasys/pantheon/metrics/LabelledMetric.java b/metrics/core/src/main/java/tech/pegasys/pantheon/metrics/LabelledMetric.java similarity index 100% rename from metrics/src/main/java/tech/pegasys/pantheon/metrics/LabelledMetric.java rename to metrics/core/src/main/java/tech/pegasys/pantheon/metrics/LabelledMetric.java diff --git a/metrics/src/main/java/tech/pegasys/pantheon/metrics/MetricCategory.java b/metrics/core/src/main/java/tech/pegasys/pantheon/metrics/MetricCategory.java similarity index 100% rename from metrics/src/main/java/tech/pegasys/pantheon/metrics/MetricCategory.java rename to metrics/core/src/main/java/tech/pegasys/pantheon/metrics/MetricCategory.java diff --git a/metrics/src/main/java/tech/pegasys/pantheon/metrics/MetricsSystem.java b/metrics/core/src/main/java/tech/pegasys/pantheon/metrics/MetricsSystem.java similarity index 100% rename from metrics/src/main/java/tech/pegasys/pantheon/metrics/MetricsSystem.java rename to metrics/core/src/main/java/tech/pegasys/pantheon/metrics/MetricsSystem.java diff --git a/metrics/src/main/java/tech/pegasys/pantheon/metrics/Observation.java b/metrics/core/src/main/java/tech/pegasys/pantheon/metrics/Observation.java similarity index 100% rename from metrics/src/main/java/tech/pegasys/pantheon/metrics/Observation.java rename to metrics/core/src/main/java/tech/pegasys/pantheon/metrics/Observation.java diff --git a/metrics/src/main/java/tech/pegasys/pantheon/metrics/OperationTimer.java b/metrics/core/src/main/java/tech/pegasys/pantheon/metrics/OperationTimer.java similarity index 100% rename from metrics/src/main/java/tech/pegasys/pantheon/metrics/OperationTimer.java rename to metrics/core/src/main/java/tech/pegasys/pantheon/metrics/OperationTimer.java diff --git a/metrics/src/main/java/tech/pegasys/pantheon/metrics/noop/NoOpCounter.java b/metrics/core/src/main/java/tech/pegasys/pantheon/metrics/noop/NoOpCounter.java similarity index 100% rename from metrics/src/main/java/tech/pegasys/pantheon/metrics/noop/NoOpCounter.java rename to metrics/core/src/main/java/tech/pegasys/pantheon/metrics/noop/NoOpCounter.java diff --git a/metrics/src/main/java/tech/pegasys/pantheon/metrics/noop/NoOpMetricsSystem.java b/metrics/core/src/main/java/tech/pegasys/pantheon/metrics/noop/NoOpMetricsSystem.java similarity index 100% rename from metrics/src/main/java/tech/pegasys/pantheon/metrics/noop/NoOpMetricsSystem.java rename to metrics/core/src/main/java/tech/pegasys/pantheon/metrics/noop/NoOpMetricsSystem.java diff --git a/metrics/src/main/java/tech/pegasys/pantheon/metrics/prometheus/CurrentValueCollector.java b/metrics/core/src/main/java/tech/pegasys/pantheon/metrics/prometheus/CurrentValueCollector.java similarity index 100% rename from metrics/src/main/java/tech/pegasys/pantheon/metrics/prometheus/CurrentValueCollector.java rename to metrics/core/src/main/java/tech/pegasys/pantheon/metrics/prometheus/CurrentValueCollector.java diff --git a/metrics/src/main/java/tech/pegasys/pantheon/metrics/prometheus/MetricsConfiguration.java b/metrics/core/src/main/java/tech/pegasys/pantheon/metrics/prometheus/MetricsConfiguration.java similarity index 100% rename from metrics/src/main/java/tech/pegasys/pantheon/metrics/prometheus/MetricsConfiguration.java rename to metrics/core/src/main/java/tech/pegasys/pantheon/metrics/prometheus/MetricsConfiguration.java diff --git a/metrics/src/main/java/tech/pegasys/pantheon/metrics/prometheus/MetricsHttpService.java b/metrics/core/src/main/java/tech/pegasys/pantheon/metrics/prometheus/MetricsHttpService.java similarity index 100% rename from metrics/src/main/java/tech/pegasys/pantheon/metrics/prometheus/MetricsHttpService.java rename to metrics/core/src/main/java/tech/pegasys/pantheon/metrics/prometheus/MetricsHttpService.java diff --git a/metrics/src/main/java/tech/pegasys/pantheon/metrics/prometheus/MetricsPushGatewayService.java b/metrics/core/src/main/java/tech/pegasys/pantheon/metrics/prometheus/MetricsPushGatewayService.java similarity index 100% rename from metrics/src/main/java/tech/pegasys/pantheon/metrics/prometheus/MetricsPushGatewayService.java rename to metrics/core/src/main/java/tech/pegasys/pantheon/metrics/prometheus/MetricsPushGatewayService.java diff --git a/metrics/src/main/java/tech/pegasys/pantheon/metrics/prometheus/MetricsService.java b/metrics/core/src/main/java/tech/pegasys/pantheon/metrics/prometheus/MetricsService.java similarity index 100% rename from metrics/src/main/java/tech/pegasys/pantheon/metrics/prometheus/MetricsService.java rename to metrics/core/src/main/java/tech/pegasys/pantheon/metrics/prometheus/MetricsService.java diff --git a/metrics/src/main/java/tech/pegasys/pantheon/metrics/prometheus/PrometheusCounter.java b/metrics/core/src/main/java/tech/pegasys/pantheon/metrics/prometheus/PrometheusCounter.java similarity index 100% rename from metrics/src/main/java/tech/pegasys/pantheon/metrics/prometheus/PrometheusCounter.java rename to metrics/core/src/main/java/tech/pegasys/pantheon/metrics/prometheus/PrometheusCounter.java diff --git a/metrics/src/main/java/tech/pegasys/pantheon/metrics/prometheus/PrometheusMetricsSystem.java b/metrics/core/src/main/java/tech/pegasys/pantheon/metrics/prometheus/PrometheusMetricsSystem.java similarity index 100% rename from metrics/src/main/java/tech/pegasys/pantheon/metrics/prometheus/PrometheusMetricsSystem.java rename to metrics/core/src/main/java/tech/pegasys/pantheon/metrics/prometheus/PrometheusMetricsSystem.java diff --git a/metrics/src/main/java/tech/pegasys/pantheon/metrics/prometheus/PrometheusTimer.java b/metrics/core/src/main/java/tech/pegasys/pantheon/metrics/prometheus/PrometheusTimer.java similarity index 100% rename from metrics/src/main/java/tech/pegasys/pantheon/metrics/prometheus/PrometheusTimer.java rename to metrics/core/src/main/java/tech/pegasys/pantheon/metrics/prometheus/PrometheusTimer.java diff --git a/metrics/src/main/java/tech/pegasys/pantheon/metrics/vertx/PoolMetricsAdapter.java b/metrics/core/src/main/java/tech/pegasys/pantheon/metrics/vertx/PoolMetricsAdapter.java similarity index 100% rename from metrics/src/main/java/tech/pegasys/pantheon/metrics/vertx/PoolMetricsAdapter.java rename to metrics/core/src/main/java/tech/pegasys/pantheon/metrics/vertx/PoolMetricsAdapter.java diff --git a/metrics/src/main/java/tech/pegasys/pantheon/metrics/vertx/VertxMetricsAdapter.java b/metrics/core/src/main/java/tech/pegasys/pantheon/metrics/vertx/VertxMetricsAdapter.java similarity index 100% rename from metrics/src/main/java/tech/pegasys/pantheon/metrics/vertx/VertxMetricsAdapter.java rename to metrics/core/src/main/java/tech/pegasys/pantheon/metrics/vertx/VertxMetricsAdapter.java diff --git a/metrics/src/main/java/tech/pegasys/pantheon/metrics/vertx/VertxMetricsAdapterFactory.java b/metrics/core/src/main/java/tech/pegasys/pantheon/metrics/vertx/VertxMetricsAdapterFactory.java similarity index 100% rename from metrics/src/main/java/tech/pegasys/pantheon/metrics/vertx/VertxMetricsAdapterFactory.java rename to metrics/core/src/main/java/tech/pegasys/pantheon/metrics/vertx/VertxMetricsAdapterFactory.java diff --git a/metrics/src/test/java/tech/pegasys/pantheon/metrics/noop/NoOpMetricsSystemTest.java b/metrics/core/src/test/java/tech/pegasys/pantheon/metrics/noop/NoOpMetricsSystemTest.java similarity index 100% rename from metrics/src/test/java/tech/pegasys/pantheon/metrics/noop/NoOpMetricsSystemTest.java rename to metrics/core/src/test/java/tech/pegasys/pantheon/metrics/noop/NoOpMetricsSystemTest.java diff --git a/metrics/src/test/java/tech/pegasys/pantheon/metrics/prometheus/MetricsHttpServiceTest.java b/metrics/core/src/test/java/tech/pegasys/pantheon/metrics/prometheus/MetricsHttpServiceTest.java similarity index 100% rename from metrics/src/test/java/tech/pegasys/pantheon/metrics/prometheus/MetricsHttpServiceTest.java rename to metrics/core/src/test/java/tech/pegasys/pantheon/metrics/prometheus/MetricsHttpServiceTest.java diff --git a/metrics/src/test/java/tech/pegasys/pantheon/metrics/prometheus/PrometheusMetricsSystemTest.java b/metrics/core/src/test/java/tech/pegasys/pantheon/metrics/prometheus/PrometheusMetricsSystemTest.java similarity index 100% rename from metrics/src/test/java/tech/pegasys/pantheon/metrics/prometheus/PrometheusMetricsSystemTest.java rename to metrics/core/src/test/java/tech/pegasys/pantheon/metrics/prometheus/PrometheusMetricsSystemTest.java diff --git a/metrics/rocksdb/build.gradle b/metrics/rocksdb/build.gradle new file mode 100644 index 0000000000..6994cb7e44 --- /dev/null +++ b/metrics/rocksdb/build.gradle @@ -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' +} diff --git a/services/kvstore/src/main/java/tech/pegasys/pantheon/services/kvstore/RocksDBStats.java b/metrics/rocksdb/src/main/java/tech/pegasys/pantheon/metrics/rocksdb/RocksDBStats.java similarity index 98% rename from services/kvstore/src/main/java/tech/pegasys/pantheon/services/kvstore/RocksDBStats.java rename to metrics/rocksdb/src/main/java/tech/pegasys/pantheon/metrics/rocksdb/RocksDBStats.java index 37a6a5c872..9853b366cd 100644 --- a/services/kvstore/src/main/java/tech/pegasys/pantheon/services/kvstore/RocksDBStats.java +++ b/metrics/rocksdb/src/main/java/tech/pegasys/pantheon/metrics/rocksdb/RocksDBStats.java @@ -10,7 +10,7 @@ * 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. */ -package tech.pegasys.pantheon.services.kvstore; +package tech.pegasys.pantheon.metrics.rocksdb; 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.TickerType; -class RocksDBStats { +public class RocksDBStats { static final List LABELS = Collections.singletonList("quantile"); static final List LABEL_50 = Collections.singletonList("0.5"); @@ -166,7 +166,7 @@ class RocksDBStats { HistogramType.READ_NUM_MERGE_OPERANDS, }; - static void registerRocksDBMetrics( + public static void registerRocksDBMetrics( final Statistics stats, final PrometheusMetricsSystem metricsSystem) { for (final TickerType ticker : TICKERS) { diff --git a/pantheon/build.gradle b/pantheon/build.gradle index 8c7d4648ab..36714361ff 100644 --- a/pantheon/build.gradle +++ b/pantheon/build.gradle @@ -39,7 +39,7 @@ dependencies { implementation project(':ethereum:permissioning') implementation project(':ethereum:p2p') implementation project(':ethereum:rlp') - implementation project(':metrics') + implementation project(':metrics:core') implementation project(':enclave') implementation project(':services:kvstore') diff --git a/services/kvstore/build.gradle b/services/kvstore/build.gradle index 457280d8d9..e8203b74ca 100644 --- a/services/kvstore/build.gradle +++ b/services/kvstore/build.gradle @@ -28,7 +28,8 @@ jar { dependencies { api project(':util') - implementation project(':metrics') + implementation project(':metrics:core') + implementation project(':metrics:rocksdb') implementation project(':services:util') implementation 'com.google.guava:guava' diff --git a/services/kvstore/src/main/java/tech/pegasys/pantheon/services/kvstore/RocksDbKeyValueStorage.java b/services/kvstore/src/main/java/tech/pegasys/pantheon/services/kvstore/RocksDbKeyValueStorage.java index 3eaf7e1704..d8eeb4efdd 100644 --- a/services/kvstore/src/main/java/tech/pegasys/pantheon/services/kvstore/RocksDbKeyValueStorage.java +++ b/services/kvstore/src/main/java/tech/pegasys/pantheon/services/kvstore/RocksDbKeyValueStorage.java @@ -16,6 +16,8 @@ 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.metrics.rocksdb.RocksDBStats; import tech.pegasys.pantheon.services.util.RocksDbUtil; import tech.pegasys.pantheon.util.bytes.BytesValue; @@ -75,7 +77,7 @@ public class RocksDbKeyValueStorage implements KeyValueStorage, Closeable { MetricCategory.KVSTORE_ROCKSDB, "read_latency_seconds", "Latency for read from RocksDB.", - rocksDbConfiguration.getLabel()) + "database") .labels(rocksDbConfiguration.getLabel()); removeLatency = metricsSystem @@ -83,7 +85,7 @@ public class RocksDbKeyValueStorage implements KeyValueStorage, Closeable { MetricCategory.KVSTORE_ROCKSDB, "remove_latency_seconds", "Latency of remove requests from RocksDB.", - rocksDbConfiguration.getLabel()) + "database") .labels(rocksDbConfiguration.getLabel()); writeLatency = metricsSystem @@ -91,7 +93,7 @@ public class RocksDbKeyValueStorage implements KeyValueStorage, Closeable { MetricCategory.KVSTORE_ROCKSDB, "write_latency_seconds", "Latency for write to RocksDB.", - rocksDbConfiguration.getLabel()) + "database") .labels(rocksDbConfiguration.getLabel()); commitLatency = metricsSystem @@ -99,9 +101,13 @@ public class RocksDbKeyValueStorage implements KeyValueStorage, Closeable { MetricCategory.KVSTORE_ROCKSDB, "commit_latency_seconds", "Latency for commits to RocksDB.", - rocksDbConfiguration.getLabel()) + "database") .labels(rocksDbConfiguration.getLabel()); + if (metricsSystem instanceof PrometheusMetricsSystem) { + RocksDBStats.registerRocksDBMetrics(stats, (PrometheusMetricsSystem) metricsSystem); + } + metricsSystem.createLongGauge( MetricCategory.KVSTORE_ROCKSDB, "rocks_db_table_readers_memory_bytes", @@ -121,7 +127,7 @@ public class RocksDbKeyValueStorage implements KeyValueStorage, Closeable { MetricCategory.KVSTORE_ROCKSDB, "rollback_count", "Number of RocksDB transactions rolled back.", - rocksDbConfiguration.getLabel()) + "database") .labels(rocksDbConfiguration.getLabel()); } catch (final RocksDBException e) { throw new StorageException(e); diff --git a/services/pipeline/build.gradle b/services/pipeline/build.gradle index f5f687727e..a21870ea7e 100644 --- a/services/pipeline/build.gradle +++ b/services/pipeline/build.gradle @@ -27,7 +27,7 @@ jar { dependencies { api project(':util') - implementation project(':metrics') + implementation project(':metrics:core') implementation 'org.apache.logging.log4j:log4j-api' implementation 'com.google.guava:guava' diff --git a/services/tasks/build.gradle b/services/tasks/build.gradle index 679ac85eef..5345c5e811 100644 --- a/services/tasks/build.gradle +++ b/services/tasks/build.gradle @@ -30,7 +30,7 @@ dependencies { compileOnly 'org.openjdk.jmh:jmh-generator-annprocess' - implementation project(':metrics') + implementation project(':metrics:core') implementation project(':services:util') implementation 'org.apache.logging.log4j:log4j-api' diff --git a/services/util/build.gradle b/services/util/build.gradle index a0ac91b6bd..1321c88d86 100644 --- a/services/util/build.gradle +++ b/services/util/build.gradle @@ -27,7 +27,7 @@ jar { dependencies { api project(':util') - implementation project(':metrics') + implementation project(':metrics:core') implementation 'org.apache.logging.log4j:log4j-api' implementation 'com.google.guava:guava' diff --git a/settings.gradle b/settings.gradle index ac020c025b..03dd520bea 100644 --- a/settings.gradle +++ b/settings.gradle @@ -14,7 +14,6 @@ rootProject.name='pantheon' include 'acceptance-tests' include 'config' -include 'consensus' include 'consensus:clique' include 'consensus:common' include 'consensus:ibft' @@ -32,7 +31,8 @@ include 'ethereum:permissioning' include 'ethereum:referencetests' include 'ethereum:rlp' include 'ethereum:trie' -include 'metrics' +include 'metrics:core' +include 'metrics:rocksdb' include 'pantheon' include 'services:kvstore' include 'services:pipeline'