davsclaus commented on code in PR #1918:
URL: 
https://github.com/apache/camel-spring-boot/pull/1918#discussion_r3889231120


##########
core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/aiobservability/CamelAiObservabilityAutoConfiguration.java:
##########
@@ -0,0 +1,64 @@
+/*
+ * 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.spring.boot.aiobservability;
+
+import org.apache.camel.CamelContext;
+import 
org.apache.camel.component.ai.observability.GenAiObservabilityProperties;
+import org.apache.camel.component.properties.PropertiesComponent;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+import org.springframework.boot.autoconfigure.AutoConfiguration;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
+import 
org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.boot.context.properties.bind.Bindable;
+import org.springframework.boot.context.properties.bind.Binder;
+import org.springframework.context.annotation.Bean;
+import org.springframework.core.env.Environment;
+
+@AutoConfiguration(after = CamelAutoConfiguration.class)
+@ConditionalOnBean(CamelAutoConfiguration.class)
+@EnableConfigurationProperties(CamelAiObservabilityConfigurationProperties.class)
+public class CamelAiObservabilityAutoConfiguration {
+
+    @Bean
+    GenAiObservabilityConfigurer genAiObservabilityConfigurer(
+            CamelContext camelContext, Environment environment, 
PropertiesComponent propertiesComponent) {
+        propertiesComponent.setCamelContext(camelContext);
+        camelContext.setPropertiesComponent(propertiesComponent);

Review Comment:
   `CamelAutoConfiguration.doConfigureCamelContext()` already calls 
`pc.setCamelContext(camelContext)` / `camelContext.setPropertiesComponent(pc)` 
on this exact singleton `PropertiesComponent` bean during context bootstrap. 
These two lines are redundant — no other feature auto-configuration in this 
module (e.g. `CamelTraceAutoConfiguration`, 
`CamelSecurityPolicyAutoConfiguration`) touches the properties component this 
way.



##########
core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/aiobservability/CamelAiObservabilityAutoConfiguration.java:
##########
@@ -0,0 +1,64 @@
+/*
+ * 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.spring.boot.aiobservability;
+
+import org.apache.camel.CamelContext;
+import 
org.apache.camel.component.ai.observability.GenAiObservabilityProperties;
+import org.apache.camel.component.properties.PropertiesComponent;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+import org.springframework.boot.autoconfigure.AutoConfiguration;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
+import 
org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.boot.context.properties.bind.Bindable;
+import org.springframework.boot.context.properties.bind.Binder;
+import org.springframework.context.annotation.Bean;
+import org.springframework.core.env.Environment;
+
+@AutoConfiguration(after = CamelAutoConfiguration.class)
+@ConditionalOnBean(CamelAutoConfiguration.class)
+@EnableConfigurationProperties(CamelAiObservabilityConfigurationProperties.class)
+public class CamelAiObservabilityAutoConfiguration {
+
+    @Bean
+    GenAiObservabilityConfigurer genAiObservabilityConfigurer(
+            CamelContext camelContext, Environment environment, 
PropertiesComponent propertiesComponent) {
+        propertiesComponent.setCamelContext(camelContext);
+        camelContext.setPropertiesComponent(propertiesComponent);
+        applyEnabledProperty(camelContext, resolveEnabled(environment));
+        return new GenAiObservabilityConfigurer();
+    }
+
+    static final class GenAiObservabilityConfigurer {
+        // marker bean
+    }

Review Comment:
   The empty "marker bean" returned solely to give this `@Bean` method a return 
type has no precedent elsewhere in this module — other autoconfigs return real 
functional beans. Minor, but consider a plainer approach.



##########
core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/aiobservability/CamelAiObservabilityAutoConfiguration.java:
##########
@@ -0,0 +1,64 @@
+/*
+ * 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.spring.boot.aiobservability;
+
+import org.apache.camel.CamelContext;
+import 
org.apache.camel.component.ai.observability.GenAiObservabilityProperties;
+import org.apache.camel.component.properties.PropertiesComponent;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+import org.springframework.boot.autoconfigure.AutoConfiguration;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
+import 
org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.boot.context.properties.bind.Bindable;
+import org.springframework.boot.context.properties.bind.Binder;
+import org.springframework.context.annotation.Bean;
+import org.springframework.core.env.Environment;
+
+@AutoConfiguration(after = CamelAutoConfiguration.class)
+@ConditionalOnBean(CamelAutoConfiguration.class)
+@EnableConfigurationProperties(CamelAiObservabilityConfigurationProperties.class)
+public class CamelAiObservabilityAutoConfiguration {
+
+    @Bean
+    GenAiObservabilityConfigurer genAiObservabilityConfigurer(
+            CamelContext camelContext, Environment environment, 
PropertiesComponent propertiesComponent) {
+        propertiesComponent.setCamelContext(camelContext);
+        camelContext.setPropertiesComponent(propertiesComponent);
+        applyEnabledProperty(camelContext, resolveEnabled(environment));
+        return new GenAiObservabilityConfigurer();
+    }
+
+    static final class GenAiObservabilityConfigurer {
+        // marker bean
+    }
+
+    static boolean resolveEnabled(Environment environment) {
+        Boolean canonical = 
environment.getProperty(GenAiObservabilityProperties.ENABLED, Boolean.class);
+        if (canonical != null) {
+            return canonical;
+        }
+        return Binder.get(environment)
+                .bind("camel.aiobservability", 
Bindable.of(CamelAiObservabilityConfigurationProperties.class))
+                .map(CamelAiObservabilityConfigurationProperties::isEnabled)
+                .orElse(true);
+    }
+
+    static void applyEnabledProperty(CamelContext camelContext, boolean 
enabled) {
+        PropertiesComponent pc = (PropertiesComponent) 
camelContext.getPropertiesComponent();
+        pc.addOverrideProperty(GenAiObservabilityProperties.ENABLED, 
Boolean.toString(enabled));

Review Comment:
   `camel-main`'s existing `AiObservabilityConfigurationProperties` 
(CAMEL-23861) writes this same `camel.aiObservability.enabled` flag into the 
PropertiesComponent's **local properties**, which take precedence over override 
properties. Using `addOverrideProperty` here works standalone but is a 
different-ranked mechanism for the identical flag — worth a comment explaining 
the choice, or aligning with camel-main's approach.



##########
core/camel-spring-boot/pom.xml:
##########
@@ -94,6 +94,10 @@
             <groupId>org.apache.camel</groupId>
             <artifactId>camel-health</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-ai-observability-api</artifactId>

Review Comment:
   This dependency (and the whole `aiobservability` auto-configuration) should 
move to a new `camel-ai-observability-starter` module rather than being a 
mandatory dependency of core. See overall review comment.



-- 
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]

Reply via email to