diff --git a/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/manager/task/AbstractPipelinedTask.java b/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/manager/task/AbstractPipelinedTask.java index 1cb44a8a73..4f41f2bc8b 100644 --- a/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/manager/task/AbstractPipelinedTask.java +++ b/ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/manager/task/AbstractPipelinedTask.java @@ -53,15 +53,21 @@ protected AbstractPipelinedTask( outboundQueue = new LinkedBlockingQueue<>(outboundBacklogSize); results = new ArrayList<>(); this.inboundQueueCounter = - metricsSystem.createCounter( - MetricCategory.SYNCHRONIZER, - "inboundQueueCounter", - "count of queue items that started processing"); + metricsSystem + .createLabelledCounter( + MetricCategory.SYNCHRONIZER, + "inboundQueueCounter", + "count of queue items that started processing", + "taskName") + .labels(getClass().getSimpleName()); this.outboundQueueCounter = - metricsSystem.createCounter( - MetricCategory.SYNCHRONIZER, - "outboundQueueCounter", - "count of queue items that finished processing"); + metricsSystem + .createLabelledCounter( + MetricCategory.SYNCHRONIZER, + "outboundQueueCounter", + "count of queue items that finished processing", + "taskName") + .labels(getClass().getSimpleName()); } @Override diff --git a/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/sync/fullsync/IncrementerTest.java b/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/sync/fullsync/IncrementerTest.java index 5aa048a448..843c3ec734 100644 --- a/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/sync/fullsync/IncrementerTest.java +++ b/ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/sync/fullsync/IncrementerTest.java @@ -34,10 +34,11 @@ import tech.pegasys.pantheon.metrics.prometheus.MetricsConfiguration; import tech.pegasys.pantheon.metrics.prometheus.PrometheusMetricsSystem; +import java.util.Arrays; +import java.util.Collections; import java.util.List; import java.util.stream.Collectors; -import org.assertj.core.util.Lists; import org.junit.Test; public class IncrementerTest { @@ -95,12 +96,43 @@ public void parallelDownloadPipelineCounterShouldIncrement() { final List metrics = metricsSystem.getMetrics(MetricCategory.SYNCHRONIZER).collect(Collectors.toList()); - final Observation inboundObservation = - new Observation(MetricCategory.SYNCHRONIZER, "inboundQueueCounter", 6.0, Lists.emptyList()); - final Observation outboundObservation = + + // the first iteration gets the genesis block, which results in no data + // being passed downstream. So observed value is 2. + final Observation headerInboundObservation = + new Observation( + MetricCategory.SYNCHRONIZER, + "inboundQueueCounter", + 2.0, + Collections.singletonList("ParallelDownloadHeadersTask")); + final Observation headerOutboundObservation = new Observation( - MetricCategory.SYNCHRONIZER, "outboundQueueCounter", 5.0, Lists.emptyList()); - assertThat(metrics).contains(inboundObservation, outboundObservation); + MetricCategory.SYNCHRONIZER, + "outboundQueueCounter", + 1.0, + Collections.singletonList("ParallelDownloadHeadersTask")); + assertThat(metrics).contains(headerInboundObservation, headerOutboundObservation); + + for (final String label : + Arrays.asList( + "ParallelValidateHeadersTask", + "ParallelDownloadBodiesTask", + "ParallelExtractTxSignaturesTask", + "ParallelValidateAndImportBodiesTask")) { + final Observation inboundObservation = + new Observation( + MetricCategory.SYNCHRONIZER, + "inboundQueueCounter", + 1.0, + Collections.singletonList(label)); + final Observation outboundObservation = + new Observation( + MetricCategory.SYNCHRONIZER, + "outboundQueueCounter", + 1.0, + Collections.singletonList(label)); + assertThat(metrics).contains(inboundObservation, outboundObservation); + } } private FullSyncDownloader downloader(final SynchronizerConfiguration syncConfig) {