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

davsclaus pushed a commit to branch export-metrics
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 5707f764705d0e5f032713a81585ba17ebdb978b
Author: Claus Ibsen <claus.ib...@gmail.com>
AuthorDate: Wed Apr 17 08:53:19 2024 +0200

    CAMEL-20669: camel-jbang - Fix export with metrics=true and also include 
camel-micromemeter-prometheus for camel-main runtime.
---
 .../component/micrometer/prometheus/MicrometerPrometheus.java    | 3 ++-
 .../apache/camel/dsl/jbang/core/commands/ExportCamelMain.java    | 9 +++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git 
a/components/camel-micrometer-prometheus/src/main/java/org/apache/camel/component/micrometer/prometheus/MicrometerPrometheus.java
 
b/components/camel-micrometer-prometheus/src/main/java/org/apache/camel/component/micrometer/prometheus/MicrometerPrometheus.java
index f90f90fccec..3adf0b9fc16 100644
--- 
a/components/camel-micrometer-prometheus/src/main/java/org/apache/camel/component/micrometer/prometheus/MicrometerPrometheus.java
+++ 
b/components/camel-micrometer-prometheus/src/main/java/org/apache/camel/component/micrometer/prometheus/MicrometerPrometheus.java
@@ -58,6 +58,7 @@ import org.apache.camel.spi.ManagementStrategy;
 import org.apache.camel.spi.Metadata;
 import org.apache.camel.spi.Registry;
 import org.apache.camel.spi.annotations.JdkService;
+import org.apache.camel.support.CamelContextHelper;
 import org.apache.camel.support.SimpleEventNotifierSupport;
 import org.apache.camel.support.service.ServiceSupport;
 import org.apache.camel.util.IOHelper;
@@ -345,7 +346,7 @@ public class MicrometerPrometheus extends ServiceSupport 
implements CamelMetrics
         super.doStart();
 
         server = camelContext.hasService(MainHttpServer.class);
-        router = VertxPlatformHttpRouter.lookup(camelContext);
+        router = CamelContextHelper.lookup(camelContext, 
"platform-http-router", VertxPlatformHttpRouter.class);
         platformHttpComponent = camelContext.getComponent("platform-http", 
PlatformHttpComponent.class);
 
         if (server != null && server.isMetricsEnabled() && router != null && 
platformHttpComponent != null) {
diff --git 
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportCamelMain.java
 
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportCamelMain.java
index 6e5fdd58e10..c45e3e7a653 100644
--- 
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportCamelMain.java
+++ 
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportCamelMain.java
@@ -302,6 +302,15 @@ class ExportCamelMain extends Export {
     protected Set<String> resolveDependencies(File settings, File profile) 
throws Exception {
         Set<String> answer = super.resolveDependencies(settings, profile);
 
+        if (profile != null && profile.exists()) {
+            Properties prop = new CamelCaseOrderedProperties();
+            RuntimeUtil.loadProperties(prop, profile);
+            // if metrics is defined then include camel-micrometer-prometheus 
for camel-main runtime
+            if (prop.getProperty("camel.metrics.enabled") != null || 
prop.getProperty("camel.server.metricsEnabled") != null) {
+                answer.add("mvn:org.apache.camel:camel-micrometer-prometheus");
+            }
+        }
+
         // remove out of the box dependencies
         answer.removeIf(s -> s.contains("camel-core"));
         answer.removeIf(s -> s.contains("camel-main"));

Reply via email to