This repository has been archived by the owner on Sep 26, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Number of metrics labels need to match up with constructor * Number of labels must be consistant, so I split it into two metrics * Also, naming best practices say that sum() and avg() of a metric should be meaningful, separating into two metrics fixes that. * fix style issues (finals, intellij warnings) * Change NoOpMetrics to check label count. * Cascading changes to support this in many support classes. Mostly places we presumed all NoOpMetrics were equals.
- Loading branch information
Showing
10 changed files
with
171 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
metrics/src/test/java/tech/pegasys/pantheon/metrics/noop/NoOpMetricsSystemTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* Copyright 2019 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. | ||
*/ | ||
package tech.pegasys.pantheon.metrics.noop; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType; | ||
|
||
import tech.pegasys.pantheon.metrics.Counter; | ||
import tech.pegasys.pantheon.metrics.LabelledMetric; | ||
import tech.pegasys.pantheon.metrics.MetricCategory; | ||
import tech.pegasys.pantheon.metrics.MetricsSystem; | ||
import tech.pegasys.pantheon.metrics.OperationTimer; | ||
|
||
import org.junit.Test; | ||
|
||
public class NoOpMetricsSystemTest { | ||
|
||
private final MetricsSystem metricsSystem = new NoOpMetricsSystem(); | ||
|
||
@Test | ||
public void labelCountsMatchOnCounter() { | ||
final LabelledMetric<Counter> labeledCounter = | ||
metricsSystem.createLabelledCounter(MetricCategory.PROCESS, "name", "help", "label1"); | ||
assertThat(labeledCounter.labels("one")).isSameAs(NoOpMetricsSystem.NO_OP_COUNTER); | ||
} | ||
|
||
@Test | ||
public void failsWheLabelCountsDoNotMatchOnCounter() { | ||
final LabelledMetric<Counter> labeledCounter = | ||
metricsSystem.createLabelledCounter( | ||
MetricCategory.PROCESS, "name", "help", "label1", "label2"); | ||
|
||
assertThatExceptionOfType(IllegalArgumentException.class) | ||
.isThrownBy(() -> labeledCounter.labels("one")) | ||
.withMessage("The count of labels used must match the count of labels expected."); | ||
assertThatExceptionOfType(IllegalArgumentException.class) | ||
.isThrownBy(() -> labeledCounter.labels("one", "two", "three")) | ||
.withMessage("The count of labels used must match the count of labels expected."); | ||
} | ||
|
||
@Test | ||
public void labelCountsMatchOnTimer() { | ||
final LabelledMetric<OperationTimer> labeledTimer = | ||
metricsSystem.createLabelledTimer(MetricCategory.PROCESS, "name", "help", "label1"); | ||
assertThat(labeledTimer.labels("one")).isSameAs(NoOpMetricsSystem.NO_OP_OPERATION_TIMER); | ||
} | ||
|
||
@Test | ||
public void failsWheLabelCountsDoNotMatchOnTimer() { | ||
final LabelledMetric<OperationTimer> labeledTimer = | ||
metricsSystem.createLabelledTimer( | ||
MetricCategory.PROCESS, "name", "help", "label1", "label2"); | ||
|
||
assertThatExceptionOfType(IllegalArgumentException.class) | ||
.isThrownBy(() -> labeledTimer.labels("one")) | ||
.withMessage("The count of labels used must match the count of labels expected."); | ||
assertThatExceptionOfType(IllegalArgumentException.class) | ||
.isThrownBy(() -> labeledTimer.labels("one", "two", "three")) | ||
.withMessage("The count of labels used must match the count of labels expected."); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.