Skip to content

Commit 73b1e5c

Browse files
committed
Improve test reliability
1 parent 8a57c8f commit 73b1e5c

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

extensions/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/common/exporter/InMemoryMetricExporter.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,6 @@ private static boolean isPathFound(String path, Attributes attributes) {
106106
return value.toString().equals(path);
107107
}
108108

109-
public void assertCount(final int count) {
110-
Awaitility.await().atMost(5, SECONDS)
111-
.untilAsserted(() -> Assertions.assertEquals(count, getFinishedMetricItems().size()));
112-
}
113-
114109
public void assertCount(final String name, final String target, final int count) {
115110
Awaitility.await().atMost(5, SECONDS)
116111
.untilAsserted(() -> Assertions.assertEquals(count, getFinishedMetricItems(name, target).size()));

extensions/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/metrics/HttpServerMetricsTest.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,10 @@ void collectsHttpRouteFromEndAttributes() {
7070
.statusCode(INTERNAL_SERVER_ERROR.getStatusCode());
7171

7272
metricExporter.assertCountPointsAtLeast("http.server.request.duration", null, 2);
73-
MetricData metric = metricExporter.getFinishedMetricItems("http.server.request.duration", null).get(0);
73+
MetricData metric = metricExporter
74+
.getFinishedMetricItems("http.server.request.duration", null).stream()
75+
.reduce((first, second) -> second) // get the last received
76+
.orElse(null);
7477

7578
assertThat(metric)
7679
.hasName("http.server.request.duration")

0 commit comments

Comments
 (0)