Copilot commented on code in PR #24425:
URL: https://github.com/apache/camel/pull/24425#discussion_r3523958512
##########
components/camel-opentelemetry-metrics/src/test/java/org/apache/camel/opentelemetry/metrics/integration/messagehistory/ManagedMessageHistoryAutoConfigIT.java:
##########
@@ -98,30 +98,34 @@ public void testMessageHistory() throws Exception {
MockEndpoint.assertIsSatisfied(context);
- await().atMost(Duration.ofMillis(1000L)).until(handler::hasLogs);
-
- List<LogRecord> logs = new ArrayList<>(handler.getLogs());
- assertFalse(logs.isEmpty(), "No metrics were exported");
- int dataCount = 0;
- for (LogRecord log : logs) {
- if (log.getParameters() != null && log.getParameters().length > 0)
{
- MetricData metricData = (MetricData) log.getParameters()[0];
- // Skip non-Camel metrics (e.g. otel.sdk.* internal metrics
added in OTel 1.60+)
- if (!metricData.getName().startsWith("camel.")) {
- continue;
+ // Use Awaitility to retry assertions until the OTel periodic reader
has exported
+ // Camel metrics. On slow CI architectures the first export may be
delayed well
+ // beyond the 300ms export interval. Assert on the last exported Camel
metric data
+ // because earlier exports during message processing may contain
incomplete data.
+ await().atMost(Duration.ofSeconds(20)).untilAsserted(() -> {
+ List<LogRecord> logs = new ArrayList<>(handler.getLogs());
+ assertFalse(logs.isEmpty(), "No metrics were exported");
+
+ MetricData lastCamelMetric = null;
Review Comment:
Test hygiene: `MemoryLogHandler` is added to the shared
`LoggingMetricExporter` logger but never removed/closed. Over the full test
suite this can accumulate handlers in the same JVM, increasing log fan-out and
potentially affecting timing. Also, `handler.getLogs()` already returns a
defensive copy, so wrapping it in `new ArrayList<>(...)` is redundant.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]