Skip to content

Commit

Permalink
Refactor RocksDBStats (#1266)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
shemnon authored Apr 13, 2019
1 parent c7947b8 commit cf2acc2
Show file tree
Hide file tree
Showing 43 changed files with 120 additions and 61 deletions.
2 changes: 1 addition & 1 deletion acceptance-tests/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion consensus/clique/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
4 changes: 2 additions & 2 deletions consensus/ibft/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
4 changes: 2 additions & 2 deletions consensus/ibftlegacy/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion ethereum/blockcreation/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
4 changes: 2 additions & 2 deletions ethereum/core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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')

Expand Down
2 changes: 1 addition & 1 deletion ethereum/eth/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion ethereum/jsonrpc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion ethereum/p2p/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
1 change: 1 addition & 0 deletions gradle/check-licenses.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
35 changes: 1 addition & 34 deletions metrics/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 47 additions & 0 deletions metrics/core/build.gradle
Original file line number Diff line number Diff line change
@@ -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'
}
37 changes: 37 additions & 0 deletions metrics/rocksdb/build.gradle
Original file line number Diff line number Diff line change
@@ -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'
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -26,7 +26,7 @@
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");
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion pantheon/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down
3 changes: 2 additions & 1 deletion services/kvstore/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
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;

Expand Down Expand Up @@ -75,33 +77,37 @@ private RocksDbKeyValueStorage(
MetricCategory.KVSTORE_ROCKSDB,
"read_latency_seconds",
"Latency for read from RocksDB.",
rocksDbConfiguration.getLabel())
"database")
.labels(rocksDbConfiguration.getLabel());
removeLatency =
metricsSystem
.createLabelledTimer(
MetricCategory.KVSTORE_ROCKSDB,
"remove_latency_seconds",
"Latency of remove requests from RocksDB.",
rocksDbConfiguration.getLabel())
"database")
.labels(rocksDbConfiguration.getLabel());
writeLatency =
metricsSystem
.createLabelledTimer(
MetricCategory.KVSTORE_ROCKSDB,
"write_latency_seconds",
"Latency for write to RocksDB.",
rocksDbConfiguration.getLabel())
"database")
.labels(rocksDbConfiguration.getLabel());
commitLatency =
metricsSystem
.createLabelledTimer(
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",
Expand All @@ -121,7 +127,7 @@ private RocksDbKeyValueStorage(
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);
Expand Down
2 changes: 1 addition & 1 deletion services/pipeline/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion services/tasks/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion services/util/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
4 changes: 2 additions & 2 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
rootProject.name='pantheon'
include 'acceptance-tests'
include 'config'
include 'consensus'
include 'consensus:clique'
include 'consensus:common'
include 'consensus:ibft'
Expand All @@ -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'
Expand Down

0 comments on commit cf2acc2

Please sign in to comment.