This is an automated email from the ASF dual-hosted git repository.

Croway pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new a0248671a3b8 CAMEL-24570: Log when GenAI observability silently falls 
back to no-op (#25989)
a0248671a3b8 is described below

commit a0248671a3b8dfbc785c138c4fd909d9d39a5136
Author: Omar Atie <[email protected]>
AuthorDate: Wed Sep 2 01:19:51 2026 -0700

    CAMEL-24570: Log when GenAI observability silently falls back to no-op 
(#25989)
    
    * CAMEL-24570: Log when GenAI observability silently falls back to no-op
    
    Emit one-time INFO (or WARN when camel.aiObservability.enabled is set
    explicitly) when:
    - camel-ai-observability implementation module is missing from classpath
    - Micrometer ObservationRegistry is used without a tracing handler
    
    Includes diagnostics unit tests and Observation backend cache reset for 
tests.
    
    Co-authored-by: Cursor Agent <[email protected]>
    
    * CAMEL-24570: Improve GenAI observability no-op diagnostics
    
    Use TracingContext detection after observation.start() instead of
    handler class-name checks. Add real DefaultTracingObservationHandler
    tests, composite handler regression coverage, and sync catalog docs.
    
    Co-authored-by: Cursor <[email protected]>
    
    * CAMEL-24570: Address review feedback on no-op diagnostics
    
    Cache TracingContext class lookup, harden bridge-unavailable tests,
    reset bridge cache in integration tests, and document new log lines
    in the 4.23 upgrade guide.
    
    Co-authored-by: Cursor <[email protected]>
    
    * CAMEL-24570: Simplify GenAI observability no-op diagnostics
    
    Address review feedback from Croway: log once from cached bridge and
    observation backend state, use INFO consistently, remove diagnostics
    helper class and doc/upgrade-guide entries, and simplify tests.
    
    Co-authored-by: Cursor <[email protected]>
    
    ---------
    
    Co-authored-by: Cursor Agent <[email protected]>
    Co-authored-by: Cursor Agent <[email protected]>
---
 .../ai/observability/GenAiObservability.java       |  3 +
 .../GenAiObservabilityMissingImplLogTest.java      | 44 ++++++++++++++
 .../component/ai/observability/LogCapture.java     | 69 ++++++++++++++++++++++
 .../src/test/resources/log4j2.properties           | 25 ++++++++
 components/camel-ai/camel-ai-observability/pom.xml | 10 ++++
 .../GenAiMicrometerObservationSupport.java         | 44 ++++++++++++++
 ...AiObservabilityMeterBeforeTracingNoLogTest.java | 59 ++++++++++++++++++
 .../GenAiObservabilityMissingTracingLogTest.java   | 57 ++++++++++++++++++
 .../GenAiObservabilityWithTracingNoLogTest.java    | 55 +++++++++++++++++
 .../component/ai/observability/LogCapture.java     | 69 ++++++++++++++++++++++
 .../src/test/resources/log4j2.properties           | 25 ++++++++
 11 files changed, 460 insertions(+)

diff --git 
a/components/camel-ai/camel-ai-observability-api/src/main/java/org/apache/camel/component/ai/observability/GenAiObservability.java
 
b/components/camel-ai/camel-ai-observability-api/src/main/java/org/apache/camel/component/ai/observability/GenAiObservability.java
index a6c5becb8003..05abf2119df6 100644
--- 
a/components/camel-ai/camel-ai-observability-api/src/main/java/org/apache/camel/component/ai/observability/GenAiObservability.java
+++ 
b/components/camel-ai/camel-ai-observability-api/src/main/java/org/apache/camel/component/ai/observability/GenAiObservability.java
@@ -84,6 +84,9 @@ public final class GenAiObservability {
     private static ImplBridge resolveBridge(CamelContext camelContext) {
         Class<?> implClass = 
camelContext.getClassResolver().resolveClass(IMPL_CLASS);
         if (implClass == null) {
+            LOG.info(
+                    "GenAI observability is enabled but camel-ai-observability 
is not on the classpath; "
+                     + "spans and metrics will not be emitted");
             return UNAVAILABLE_BRIDGE;
         }
         try {
diff --git 
a/components/camel-ai/camel-ai-observability-api/src/test/java/org/apache/camel/component/ai/observability/GenAiObservabilityMissingImplLogTest.java
 
b/components/camel-ai/camel-ai-observability-api/src/test/java/org/apache/camel/component/ai/observability/GenAiObservabilityMissingImplLogTest.java
new file mode 100644
index 000000000000..cd0420be19af
--- /dev/null
+++ 
b/components/camel-ai/camel-ai-observability-api/src/test/java/org/apache/camel/component/ai/observability/GenAiObservabilityMissingImplLogTest.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.ai.observability;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.support.DefaultExchange;
+import org.apache.camel.test.junit6.ExchangeTestSupport;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+class GenAiObservabilityMissingImplLogTest extends ExchangeTestSupport {
+
+    @Test
+    void shouldLogInfoOnceWhenImplementationIsMissing() {
+        try (LogCapture capture = LogCapture.attach(GenAiObservability.class)) 
{
+            Exchange exchange = new DefaultExchange(context);
+            GenAiObservationContext observationContext = 
GenAiObservationContext.builder()
+                    .operationName(GenAiOperationName.CHAT)
+                    .requestModel("gpt-4o")
+                    .build();
+            GenAiObservability.start(exchange, observationContext).close();
+            GenAiObservability.start(exchange, observationContext).close();
+
+            assertThat(capture.infoMessages()).hasSize(1);
+            assertThat(capture.infoMessages().get(0))
+                    .contains("camel-ai-observability is not on the 
classpath");
+        }
+    }
+}
diff --git 
a/components/camel-ai/camel-ai-observability-api/src/test/java/org/apache/camel/component/ai/observability/LogCapture.java
 
b/components/camel-ai/camel-ai-observability-api/src/test/java/org/apache/camel/component/ai/observability/LogCapture.java
new file mode 100644
index 000000000000..e448cc993d77
--- /dev/null
+++ 
b/components/camel-ai/camel-ai-observability-api/src/test/java/org/apache/camel/component/ai/observability/LogCapture.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.ai.observability;
+
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.core.LogEvent;
+import org.apache.logging.log4j.core.Logger;
+import org.apache.logging.log4j.core.appender.AbstractAppender;
+import org.apache.logging.log4j.core.config.Property;
+
+final class LogCapture implements AutoCloseable {
+
+    private final Logger logger;
+    private final AbstractAppender appender;
+    private final List<String> infoMessages = new CopyOnWriteArrayList<>();
+    private final List<String> warnMessages = new CopyOnWriteArrayList<>();
+
+    private LogCapture(Class<?> type) {
+        appender = new AbstractAppender("GenAiObservabilityCapture", null, 
null, true, Property.EMPTY_ARRAY) {
+            @Override
+            public void append(LogEvent event) {
+                if (event.getLevel() == Level.INFO) {
+                    infoMessages.add(event.getMessage().getFormattedMessage());
+                } else if (event.getLevel() == Level.WARN) {
+                    warnMessages.add(event.getMessage().getFormattedMessage());
+                }
+            }
+        };
+        appender.start();
+        logger = (Logger) LogManager.getLogger(type);
+        logger.addAppender(appender);
+    }
+
+    static LogCapture attach(Class<?> type) {
+        return new LogCapture(type);
+    }
+
+    List<String> infoMessages() {
+        return infoMessages;
+    }
+
+    List<String> warnMessages() {
+        return warnMessages;
+    }
+
+    @Override
+    public void close() {
+        logger.removeAppender(appender);
+        appender.stop();
+    }
+}
diff --git 
a/components/camel-ai/camel-ai-observability-api/src/test/resources/log4j2.properties
 
b/components/camel-ai/camel-ai-observability-api/src/test/resources/log4j2.properties
new file mode 100644
index 000000000000..5fc6e4a4b330
--- /dev/null
+++ 
b/components/camel-ai/camel-ai-observability-api/src/test/resources/log4j2.properties
@@ -0,0 +1,25 @@
+## ---------------------------------------------------------------------------
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements.  See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You under the Apache License, Version 2.0
+## (the "License"); you may not use this file except in compliance with
+## the License.  You may obtain a copy of the License at
+##
+##      http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+## ---------------------------------------------------------------------------
+
+appender.file.type = File
+appender.file.name = file
+appender.file.fileName = target/camel-ai-observability-api-test.log
+appender.file.layout.type = PatternLayout
+appender.file.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n
+
+rootLogger.level = INFO
+rootLogger.appenderRef.file.ref = file
diff --git a/components/camel-ai/camel-ai-observability/pom.xml 
b/components/camel-ai/camel-ai-observability/pom.xml
index 508bf3e7c2a7..465143cccb26 100644
--- a/components/camel-ai/camel-ai-observability/pom.xml
+++ b/components/camel-ai/camel-ai-observability/pom.xml
@@ -71,6 +71,16 @@
             <optional>true</optional>
         </dependency>
 
+        <dependency>
+            <groupId>io.micrometer</groupId>
+            <artifactId>micrometer-tracing</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>io.micrometer</groupId>
+            <artifactId>micrometer-tracing-test</artifactId>
+            <scope>test</scope>
+        </dependency>
         <dependency>
             <groupId>org.apache.camel</groupId>
             <artifactId>camel-test-junit6</artifactId>
diff --git 
a/components/camel-ai/camel-ai-observability/src/main/java/org/apache/camel/component/ai/observability/GenAiMicrometerObservationSupport.java
 
b/components/camel-ai/camel-ai-observability/src/main/java/org/apache/camel/component/ai/observability/GenAiMicrometerObservationSupport.java
index 9096c252953b..45173d8187dc 100644
--- 
a/components/camel-ai/camel-ai-observability/src/main/java/org/apache/camel/component/ai/observability/GenAiMicrometerObservationSupport.java
+++ 
b/components/camel-ai/camel-ai-observability/src/main/java/org/apache/camel/component/ai/observability/GenAiMicrometerObservationSupport.java
@@ -16,11 +16,15 @@
  */
 package org.apache.camel.component.ai.observability;
 
+import java.util.concurrent.atomic.AtomicBoolean;
+
 import io.micrometer.observation.Observation;
 import io.micrometer.observation.ObservationRegistry;
 import org.apache.camel.CamelContext;
 import org.apache.camel.support.CamelContextHelper;
 import org.apache.camel.util.ObjectHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Micrometer Observation-backed instrumentation. Loaded reflectively only 
when {@link ObservationRegistry} is on the
@@ -28,7 +32,14 @@ import org.apache.camel.util.ObjectHelper;
  */
 final class GenAiMicrometerObservationSupport implements 
GenAiMicrometerObservationBackend {
 
+    private static final Logger LOG = 
LoggerFactory.getLogger(GenAiMicrometerObservationSupport.class);
+    private static final String TRACING_CONTEXT_CLASS_NAME
+            = 
"io.micrometer.tracing.handler.TracingObservationHandler$TracingContext";
+    private static volatile Class<?> tracingContextClass;
+    private static volatile boolean tracingContextClassResolved;
+
     private final ObservationRegistry observationRegistry;
+    private final AtomicBoolean missingTracingReported = new AtomicBoolean();
 
     GenAiMicrometerObservationSupport(CamelContext camelContext) {
         ObservationRegistry registry = 
CamelContextHelper.findSingleByType(camelContext, ObservationRegistry.class);
@@ -57,6 +68,12 @@ final class GenAiMicrometerObservationSupport implements 
GenAiMicrometerObservat
         if (observation.isNoop()) {
             return null;
         }
+        if (!hasTracingContext(observation)
+                && missingTracingReported.compareAndSet(false, true)) {
+            LOG.info(
+                    "No Micrometer tracing context was created for GenAI 
observations; "
+                     + "configure a tracing handler and exporter");
+        }
         try {
             return new ObservationHandle(observation, observation.openScope());
         } catch (RuntimeException e) {
@@ -69,6 +86,33 @@ final class GenAiMicrometerObservationSupport implements 
GenAiMicrometerObservat
         return registry != null && registry != ObservationRegistry.NOOP;
     }
 
+    private static boolean hasTracingContext(Observation observation) {
+        Class<?> contextClass = resolveTracingContextClass();
+        if (contextClass == null) {
+            return false;
+        }
+        return observation.getContextView().get(contextClass) != null;
+    }
+
+    private static Class<?> resolveTracingContextClass() {
+        if (!tracingContextClassResolved) {
+            synchronized (GenAiMicrometerObservationSupport.class) {
+                if (!tracingContextClassResolved) {
+                    try {
+                        tracingContextClass = 
Class.forName(TRACING_CONTEXT_CLASS_NAME);
+                    } catch (ClassNotFoundException e) {
+                        if (LOG.isDebugEnabled()) {
+                            LOG.debug("Micrometer tracing context unavailable 
for GenAI observation diagnostics", e);
+                        }
+                        tracingContextClass = null;
+                    }
+                    tracingContextClassResolved = true;
+                }
+            }
+        }
+        return tracingContextClass;
+    }
+
     private static String nullToUnknown(String value) {
         return value == null || value.isBlank() ? "unknown" : value;
     }
diff --git 
a/components/camel-ai/camel-ai-observability/src/test/java/org/apache/camel/component/ai/observability/GenAiObservabilityMeterBeforeTracingNoLogTest.java
 
b/components/camel-ai/camel-ai-observability/src/test/java/org/apache/camel/component/ai/observability/GenAiObservabilityMeterBeforeTracingNoLogTest.java
new file mode 100644
index 000000000000..907388711568
--- /dev/null
+++ 
b/components/camel-ai/camel-ai-observability/src/test/java/org/apache/camel/component/ai/observability/GenAiObservabilityMeterBeforeTracingNoLogTest.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.ai.observability;
+
+import 
io.micrometer.core.instrument.observation.DefaultMeterObservationHandler;
+import io.micrometer.core.instrument.simple.SimpleMeterRegistry;
+import io.micrometer.observation.ObservationRegistry;
+import io.micrometer.tracing.handler.DefaultTracingObservationHandler;
+import io.micrometer.tracing.test.simple.SimpleTracer;
+import org.apache.camel.Exchange;
+import org.apache.camel.support.DefaultExchange;
+import org.apache.camel.test.junit6.ExchangeTestSupport;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+class GenAiObservabilityMeterBeforeTracingNoLogTest extends 
ExchangeTestSupport {
+
+    @Test
+    void shouldNotLogWhenMeterHandlerIsRegisteredBeforeTracingHandler() {
+        SimpleMeterRegistry meters = new SimpleMeterRegistry();
+        ObservationRegistry observationRegistry = ObservationRegistry.create();
+        observationRegistry.observationConfig()
+                .observationHandler(new DefaultMeterObservationHandler(meters))
+                .observationHandler(new DefaultTracingObservationHandler(new 
SimpleTracer()));
+        context.getRegistry().bind("observationRegistry", observationRegistry);
+
+        try (LogCapture capture = 
LogCapture.attach(GenAiMicrometerObservationSupport.class)) {
+            observeTwice();
+            assertThat(capture.infoMessages()).isEmpty();
+        }
+    }
+
+    private void observeTwice() {
+        GenAiObservationContext observationContext = 
GenAiObservationContext.builder()
+                .operationName(GenAiOperationName.CHAT)
+                .system("openai")
+                .requestModel("test-model")
+                .componentScheme("langchain4j-chat")
+                .build();
+        Exchange exchange = new DefaultExchange(context);
+        GenAiObservability.start(exchange, observationContext).close();
+        GenAiObservability.start(exchange, observationContext).close();
+    }
+}
diff --git 
a/components/camel-ai/camel-ai-observability/src/test/java/org/apache/camel/component/ai/observability/GenAiObservabilityMissingTracingLogTest.java
 
b/components/camel-ai/camel-ai-observability/src/test/java/org/apache/camel/component/ai/observability/GenAiObservabilityMissingTracingLogTest.java
new file mode 100644
index 000000000000..a2417b3397c6
--- /dev/null
+++ 
b/components/camel-ai/camel-ai-observability/src/test/java/org/apache/camel/component/ai/observability/GenAiObservabilityMissingTracingLogTest.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.ai.observability;
+
+import 
io.micrometer.core.instrument.observation.DefaultMeterObservationHandler;
+import io.micrometer.core.instrument.simple.SimpleMeterRegistry;
+import io.micrometer.observation.ObservationRegistry;
+import org.apache.camel.Exchange;
+import org.apache.camel.support.DefaultExchange;
+import org.apache.camel.test.junit6.ExchangeTestSupport;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+class GenAiObservabilityMissingTracingLogTest extends ExchangeTestSupport {
+
+    @Test
+    void shouldLogInfoOnceWhenObservationRegistryHasNoTracingHandler() {
+        SimpleMeterRegistry meters = new SimpleMeterRegistry();
+        ObservationRegistry observationRegistry = ObservationRegistry.create();
+        observationRegistry.observationConfig()
+                .observationHandler(new 
DefaultMeterObservationHandler(meters));
+        context.getRegistry().bind("observationRegistry", observationRegistry);
+
+        try (LogCapture capture = 
LogCapture.attach(GenAiMicrometerObservationSupport.class)) {
+            observeTwice();
+            assertThat(capture.infoMessages()).hasSize(1);
+            assertThat(capture.infoMessages().get(0)).contains("No Micrometer 
tracing context was created");
+        }
+    }
+
+    private void observeTwice() {
+        GenAiObservationContext observationContext = 
GenAiObservationContext.builder()
+                .operationName(GenAiOperationName.CHAT)
+                .system("openai")
+                .requestModel("test-model")
+                .componentScheme("langchain4j-chat")
+                .build();
+        Exchange exchange = new DefaultExchange(context);
+        GenAiObservability.start(exchange, observationContext).close();
+        GenAiObservability.start(exchange, observationContext).close();
+    }
+}
diff --git 
a/components/camel-ai/camel-ai-observability/src/test/java/org/apache/camel/component/ai/observability/GenAiObservabilityWithTracingNoLogTest.java
 
b/components/camel-ai/camel-ai-observability/src/test/java/org/apache/camel/component/ai/observability/GenAiObservabilityWithTracingNoLogTest.java
new file mode 100644
index 000000000000..f4b9b5e27f7e
--- /dev/null
+++ 
b/components/camel-ai/camel-ai-observability/src/test/java/org/apache/camel/component/ai/observability/GenAiObservabilityWithTracingNoLogTest.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.ai.observability;
+
+import io.micrometer.observation.ObservationRegistry;
+import io.micrometer.tracing.handler.DefaultTracingObservationHandler;
+import io.micrometer.tracing.test.simple.SimpleTracer;
+import org.apache.camel.Exchange;
+import org.apache.camel.support.DefaultExchange;
+import org.apache.camel.test.junit6.ExchangeTestSupport;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+class GenAiObservabilityWithTracingNoLogTest extends ExchangeTestSupport {
+
+    @Test
+    void shouldNotLogWhenObservationRegistryHasTracingHandler() {
+        ObservationRegistry observationRegistry = ObservationRegistry.create();
+        observationRegistry.observationConfig()
+                .observationHandler(new DefaultTracingObservationHandler(new 
SimpleTracer()));
+        context.getRegistry().bind("observationRegistry", observationRegistry);
+
+        try (LogCapture capture = 
LogCapture.attach(GenAiMicrometerObservationSupport.class)) {
+            observeTwice();
+            assertThat(capture.infoMessages()).isEmpty();
+        }
+    }
+
+    private void observeTwice() {
+        GenAiObservationContext observationContext = 
GenAiObservationContext.builder()
+                .operationName(GenAiOperationName.CHAT)
+                .system("openai")
+                .requestModel("test-model")
+                .componentScheme("langchain4j-chat")
+                .build();
+        Exchange exchange = new DefaultExchange(context);
+        GenAiObservability.start(exchange, observationContext).close();
+        GenAiObservability.start(exchange, observationContext).close();
+    }
+}
diff --git 
a/components/camel-ai/camel-ai-observability/src/test/java/org/apache/camel/component/ai/observability/LogCapture.java
 
b/components/camel-ai/camel-ai-observability/src/test/java/org/apache/camel/component/ai/observability/LogCapture.java
new file mode 100644
index 000000000000..e448cc993d77
--- /dev/null
+++ 
b/components/camel-ai/camel-ai-observability/src/test/java/org/apache/camel/component/ai/observability/LogCapture.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.ai.observability;
+
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.core.LogEvent;
+import org.apache.logging.log4j.core.Logger;
+import org.apache.logging.log4j.core.appender.AbstractAppender;
+import org.apache.logging.log4j.core.config.Property;
+
+final class LogCapture implements AutoCloseable {
+
+    private final Logger logger;
+    private final AbstractAppender appender;
+    private final List<String> infoMessages = new CopyOnWriteArrayList<>();
+    private final List<String> warnMessages = new CopyOnWriteArrayList<>();
+
+    private LogCapture(Class<?> type) {
+        appender = new AbstractAppender("GenAiObservabilityCapture", null, 
null, true, Property.EMPTY_ARRAY) {
+            @Override
+            public void append(LogEvent event) {
+                if (event.getLevel() == Level.INFO) {
+                    infoMessages.add(event.getMessage().getFormattedMessage());
+                } else if (event.getLevel() == Level.WARN) {
+                    warnMessages.add(event.getMessage().getFormattedMessage());
+                }
+            }
+        };
+        appender.start();
+        logger = (Logger) LogManager.getLogger(type);
+        logger.addAppender(appender);
+    }
+
+    static LogCapture attach(Class<?> type) {
+        return new LogCapture(type);
+    }
+
+    List<String> infoMessages() {
+        return infoMessages;
+    }
+
+    List<String> warnMessages() {
+        return warnMessages;
+    }
+
+    @Override
+    public void close() {
+        logger.removeAppender(appender);
+        appender.stop();
+    }
+}
diff --git 
a/components/camel-ai/camel-ai-observability/src/test/resources/log4j2.properties
 
b/components/camel-ai/camel-ai-observability/src/test/resources/log4j2.properties
new file mode 100644
index 000000000000..346ccd5348ee
--- /dev/null
+++ 
b/components/camel-ai/camel-ai-observability/src/test/resources/log4j2.properties
@@ -0,0 +1,25 @@
+## ---------------------------------------------------------------------------
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements.  See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You under the Apache License, Version 2.0
+## (the "License"); you may not use this file except in compliance with
+## the License.  You may obtain a copy of the License at
+##
+##      http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+## ---------------------------------------------------------------------------
+
+appender.file.type = File
+appender.file.name = file
+appender.file.fileName = target/camel-ai-observability-test.log
+appender.file.layout.type = PatternLayout
+appender.file.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n
+
+rootLogger.level = INFO
+rootLogger.appenderRef.file.ref = file

Reply via email to