Skip to content

Commit 747f022

Browse files
committed
fix the skip dimension validation issue
1 parent e55ce3e commit 747f022

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

validator/src/main/java/com/amazon/aoc/validators/MetricValidator.java

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import java.util.Arrays;
3838
import java.util.Comparator;
3939
import java.util.HashMap;
40+
import java.util.HashSet;
4041
import java.util.List;
4142
import java.util.Set;
4243
import java.util.TreeSet;
@@ -54,7 +55,21 @@ public class MetricValidator implements IValidator {
5455
@Override
5556
public void validate() throws Exception {
5657
log.info("Start metric validating");
58+
// get expected metrics and remove the to be skipped dimensions
5759
final List<Metric> expectedMetricList = this.getExpectedMetricList(context);
60+
Set<String> skippedDimensionNameList = new HashSet<>();
61+
for(Metric metric: expectedMetricList){
62+
for(Dimension dimension: metric.getDimensions()){
63+
if(dimension.getValue().equals("SKIP")){
64+
skippedDimensionNameList.add(dimension.getName());
65+
}
66+
}
67+
}
68+
for (Metric metric : expectedMetricList) {
69+
metric.getDimensions().removeIf((dimension) -> skippedDimensionNameList.contains(dimension.getName()));
70+
}
71+
72+
// get metric from cloudwatch
5873
CloudWatchService cloudWatchService = new CloudWatchService(context.getRegion());
5974
RetryHelper.retry(
6075
MAX_RETRY_COUNT,
@@ -63,11 +78,9 @@ public void validate() throws Exception {
6378
this.listMetricFromCloudWatch(cloudWatchService, expectedMetricList);
6479

6580
// remove the skip dimensions
66-
for (Metric metric : expectedMetricList) {
67-
metric.getDimensions().removeIf(dimension -> dimension.getValue().equals("SKIP"));
68-
}
81+
log.info("dimensions to be skipped in validation: {}", skippedDimensionNameList);
6982
for (Metric metric : metricList) {
70-
metric.getDimensions().removeIf(dimension -> dimension.getValue().equals("SKIP"));
83+
metric.getDimensions().removeIf((dimension) -> skippedDimensionNameList.contains(dimension.getName()));
7184
}
7285

7386
log.info("check if all the expected metrics are found");

0 commit comments

Comments
 (0)