mirror of
https://github.com/vacp2p/linea-besu.git
synced 2026-01-09 21:17:54 -05:00
Fix registration of RocksDB metrics categories (#7879)
Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
This commit is contained in:
@@ -14,12 +14,18 @@
|
||||
*/
|
||||
package org.hyperledger.besu.cli.options;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.hyperledger.besu.metrics.BesuMetricCategory;
|
||||
import org.hyperledger.besu.metrics.MetricCategoryRegistryImpl;
|
||||
import org.hyperledger.besu.metrics.StandardMetricCategory;
|
||||
import org.hyperledger.besu.metrics.prometheus.MetricsConfiguration;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
@@ -64,4 +70,22 @@ public class MetricsOptionsTest
|
||||
protected String[] getNonOptionFields() {
|
||||
return new String[] {"metricCategoryRegistry"};
|
||||
}
|
||||
|
||||
@Test
|
||||
public void enableRocksDbCategories() {
|
||||
final var rocksDbMetricsCategories =
|
||||
EnumSet.of(
|
||||
BesuMetricCategory.KVSTORE_ROCKSDB,
|
||||
BesuMetricCategory.KVSTORE_ROCKSDB_STATS,
|
||||
BesuMetricCategory.KVSTORE_PRIVATE_ROCKSDB,
|
||||
BesuMetricCategory.KVSTORE_PRIVATE_ROCKSDB_STATS);
|
||||
|
||||
internalTestSuccess(
|
||||
metricsConfBuilder -> {
|
||||
assertThat(metricsConfBuilder.build().getMetricCategories())
|
||||
.containsExactlyInAnyOrderElementsOf(rocksDbMetricsCategories);
|
||||
},
|
||||
"--metrics-categories",
|
||||
rocksDbMetricsCategories.stream().map(Enum::name).collect(Collectors.joining(",")));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,8 @@ public class MetricCategoryRegistryImpl implements MetricCategoryRegistry {
|
||||
* @param categoryEnum the category enum
|
||||
*/
|
||||
public <T extends Enum<T> & MetricCategory> void addCategories(final Class<T> categoryEnum) {
|
||||
EnumSet.allOf(categoryEnum).forEach(this::addMetricCategory);
|
||||
EnumSet.allOf(categoryEnum)
|
||||
.forEach(category -> metricCategories.put(category.name(), category));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user