|
19 | 19 | import com.microsoft.applicationinsights.smoketest.schemav2.MetricData; |
20 | 20 | import io.opentelemetry.proto.metrics.v1.Metric; |
21 | 21 | import java.util.Arrays; |
22 | | -import java.util.HashMap; |
23 | 22 | import java.util.HashSet; |
24 | 23 | import java.util.List; |
25 | | -import java.util.Map; |
26 | 24 | import java.util.Set; |
27 | 25 | import java.util.concurrent.TimeUnit; |
28 | 26 | import org.junit.jupiter.api.Test; |
@@ -107,27 +105,10 @@ private void verifyJmxMetricsSentToOtlpEndpoint() { |
107 | 105 | List<Metric> metrics = |
108 | 106 | testing.mockedOtlpIngestion.extractMetricsFromRequests(requests); |
109 | 107 |
|
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); |
131 | 112 | }); |
132 | 113 | } |
133 | 114 |
|
|
0 commit comments