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>
This commit is contained in:
Danno Ferrin
2019-04-12 21:15:33 -06:00
committed by GitHub
parent c7947b8185
commit cf2acc2a75
43 changed files with 120 additions and 61 deletions

View File

@@ -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')

View File

@@ -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'

View File

@@ -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'

View File

@@ -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'

View File

@@ -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'

View File

@@ -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')

View File

@@ -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')

View File

@@ -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'

View File

@@ -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'

View File

@@ -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

View File

@@ -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 }

47
metrics/core/build.gradle Normal file
View File

@@ -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'
}

View File

@@ -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'
}

View File

@@ -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<String> LABELS = Collections.singletonList("quantile");
static final List<String> 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) {

View File

@@ -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')

View File

@@ -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'

View File

@@ -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);

View File

@@ -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'

View File

@@ -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'

View File

@@ -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'

View File

@@ -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'