Push Metrics don't work (#1164)

When we added the no-op metrics optimization this broke push-metrics.


Signed-off-by: Adrian Sutton <adrian.sutton@consensys.net>
pull/2/head
Danno Ferrin 6 years ago committed by GitHub
parent c2f2e7212a
commit 69818f6f92
  1. 2
      metrics/src/main/java/tech/pegasys/pantheon/metrics/prometheus/PrometheusMetricsSystem.java
  2. 30
      metrics/src/test/java/tech/pegasys/pantheon/metrics/prometheus/PrometheusMetricsSystemTest.java
  3. 2
      pantheon/src/main/java/tech/pegasys/pantheon/cli/BlocksSubCommand.java

@ -61,7 +61,7 @@ public class PrometheusMetricsSystem implements MetricsSystem {
PrometheusMetricsSystem() {}
public static MetricsSystem init(final MetricsConfiguration metricsConfiguration) {
if (!metricsConfiguration.isEnabled()) {
if (!metricsConfiguration.isEnabled() && !metricsConfiguration.isPushEnabled()) {
return new NoOpMetricsSystem();
}
final PrometheusMetricsSystem metricsSystem = new PrometheusMetricsSystem();

@ -195,4 +195,34 @@ public class PrometheusMetricsSystemTest {
assertThat(localMetricSystem.getMetrics())
.containsExactly(new Observation(RPC, "name", 1.0, singletonList("op")));
}
@Test
public void returnsNoOpMetricsWhenAllDisabled() {
final MetricsConfiguration metricsConfiguration = MetricsConfiguration.createDefault();
metricsConfiguration.setEnabled(false);
metricsConfiguration.setPushEnabled(false);
final MetricsSystem localMetricSystem = PrometheusMetricsSystem.init(metricsConfiguration);
assertThat(localMetricSystem).isInstanceOf(NoOpMetricsSystem.class);
}
@Test
public void returnsPrometheusMetricsWhenEnabled() {
final MetricsConfiguration metricsConfiguration = MetricsConfiguration.createDefault();
metricsConfiguration.setEnabled(true);
metricsConfiguration.setPushEnabled(false);
final MetricsSystem localMetricSystem = PrometheusMetricsSystem.init(metricsConfiguration);
assertThat(localMetricSystem).isInstanceOf(PrometheusMetricsSystem.class);
}
@Test
public void returnsNoOpMetricsWhenPushEnabled() {
final MetricsConfiguration metricsConfiguration = MetricsConfiguration.createDefault();
metricsConfiguration.setEnabled(false);
metricsConfiguration.setPushEnabled(true);
final MetricsSystem localMetricSystem = PrometheusMetricsSystem.init(metricsConfiguration);
assertThat(localMetricSystem).isInstanceOf(PrometheusMetricsSystem.class);
}
}

@ -105,7 +105,7 @@ class BlocksSubCommand implements Runnable {
try {
final MetricsConfiguration metricsConfiguration =
parentCommand.parentCommand.metricsConfiguration();
if (metricsConfiguration.isEnabled()) {
if (metricsConfiguration.isEnabled() || metricsConfiguration.isPushEnabled()) {
metricsService =
Optional.of(
MetricsService.create(

Loading…
Cancel
Save