Skip to content

Commit 632ea94

Browse files
committed
Fix sporadically failing JmxMetricTest
1 parent e549eb4 commit 632ea94

File tree

1 file changed

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

1 file changed

+4
-21
lines changed

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

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -107,27 +107,10 @@ private void verifyJmxMetricsSentToOtlpEndpoint() {
107107
List<Metric> metrics =
108108
testing.mockedOtlpIngestion.extractMetricsFromRequests(requests);
109109

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-
}
110+
// check the jmx metrics that are applicable to all java versions
111+
assertThat(metrics)
112+
.extracting(Metric::getName)
113+
.containsAll(jmxMetricsAllJavaVersionsOtlp);
131114
});
132115
}
133116

0 commit comments

Comments
 (0)