This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch camel-4.4.x in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/camel-4.4.x by this push: new 87418897c6d CAMEL-20669: camel-jbang - Fix export with metrics=true and also include camel-micromemeter-prometheus for camel-main runtime. 87418897c6d is described below commit 87418897c6d13b5b11de892dcc5c4ddfff844cc0 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 63289d4b668..cf34aad5e25 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; @@ -320,7 +321,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 c12f14dbf51..5915e91f2c5 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 @@ -300,6 +300,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"));