Skip to content

Commit 6933c4f

Browse files
committed
Fix sporadically failing JmxMetricTest
1 parent e549eb4 commit 6933c4f

File tree

1 file changed

+4
-23
lines changed
  • smoke-tests/apps/JmxMetric/src/smokeTest/java/com/microsoft/applicationinsights/smoketest

1 file changed

+4
-23
lines changed

smoke-tests/apps/JmxMetric/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/JmxMetricTest.java

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,8 @@
1919
import com.microsoft.applicationinsights.smoketest.schemav2.MetricData;
2020
import io.opentelemetry.proto.metrics.v1.Metric;
2121
import java.util.Arrays;
22-
import java.util.HashMap;
2322
import java.util.HashSet;
2423
import java.util.List;
25-
import java.util.Map;
2624
import java.util.Set;
2725
import java.util.concurrent.TimeUnit;
2826
import org.junit.jupiter.api.Test;
@@ -107,27 +105,10 @@ private void verifyJmxMetricsSentToOtlpEndpoint() {
107105
List<Metric> metrics =
108106
testing.mockedOtlpIngestion.extractMetricsFromRequests(requests);
109107

110-
Map<String, Integer> occurrences = new HashMap<>();
111-
112-
// counting all occurrences of the jmx metrics that are applicable to all java
113-
// versions
114-
for (Metric metric : metrics) {
115-
String metricName = metric.getName();
116-
if (jmxMetricsAllJavaVersionsOtlp.contains(metricName)) {
117-
if (occurrences.containsKey(metricName)) {
118-
occurrences.put(metricName, occurrences.get(metricName) + 1);
119-
} else {
120-
occurrences.put(metricName, 1);
121-
}
122-
}
123-
}
124-
125-
// confirm that those metrics received once or twice
126-
// (the collector seems to run for 5-10 sec)
127-
assertThat(occurrences.keySet()).hasSize(jmxMetricsAllJavaVersionsOtlp.size());
128-
for (int value : occurrences.values()) {
129-
assertThat(value).isBetween(1, 8);
130-
}
108+
// check the jmx metrics that are applicable to all java versions
109+
assertThat(metrics)
110+
.extracting(Metric::getName)
111+
.containsAll(jmxMetricsAllJavaVersionsOtlp);
131112
});
132113
}
133114

0 commit comments

Comments
 (0)