diff --git a/extensions/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/common/exporter/InMemoryMetricExporter.java b/extensions/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/common/exporter/InMemoryMetricExporter.java index 56e548f9167c5..1abb8874bede2 100644 --- a/extensions/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/common/exporter/InMemoryMetricExporter.java +++ b/extensions/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/common/exporter/InMemoryMetricExporter.java @@ -131,7 +131,12 @@ public void assertCountPointsAtLeast(final String name, final String target, fin .untilAsserted(() -> { List metricData = getFinishedMetricItems(name, target); Assertions.assertTrue(1 <= metricData.size()); - Assertions.assertTrue(countPoints <= metricData.get(0).getData().getPoints().size()); + Assertions.assertTrue(countPoints <= metricData.stream() + .reduce((first, second) -> second) // get the last received + .orElse(null) + .getData() + .getPoints() + .size()); }); } diff --git a/integration-tests/opentelemetry-vertx-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/exporter/AbstractExporterTest.java b/integration-tests/opentelemetry-vertx-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/exporter/AbstractExporterTest.java index 1ba0b74775661..980bebaed537b 100644 --- a/integration-tests/opentelemetry-vertx-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/exporter/AbstractExporterTest.java +++ b/integration-tests/opentelemetry-vertx-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/exporter/AbstractExporterTest.java @@ -132,17 +132,21 @@ private Metric getMetric(final String metricName) { .atMost(Duration.ofSeconds(30)) .untilAsserted(() -> { List reqs = metrics.getMetricRequests(); - assertThat(reqs).hasSizeGreaterThan(1); + Optional metric = getMetric(metricName, reqs); + assertThat(metric).isPresent(); }); final List metricRequests = metrics.getMetricRequests(); + return getMetric(metricName, metricRequests).get(); + } + private Optional getMetric(String metricName, List metricRequests) { return metricRequests.stream() .flatMap(reqs -> reqs.getResourceMetricsList().stream()) .flatMap(resourceMetrics -> resourceMetrics.getScopeMetricsList().stream()) .flatMap(libraryMetrics -> libraryMetrics.getMetricsList().stream()) .filter(metric -> metric.getName().equals(metricName)) - .findFirst().get(); + .findFirst(); } private void verifyLogs() {