You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2023/11/16 14:50:36 UTC
(camel) branch mm created (now 5e5a98c6947)
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a change to branch mm
in repository https://gitbox.apache.org/repos/asf/camel.git
at 5e5a98c6947 CAMEL-20105: camel-micromemter - Make it easier to configure for camel-main
This branch includes the following new commits:
new 2b270a72a1e CAMEL-20105: camel-micromemter - Make it easier to configure for camel-main
new 4990669db6e CAMEL-20105: camel-micromemter - Make it easier to configure for camel-main
new 5b61a3e506b CAMEL-20105: camel-micromemter - Make it easier to configure for camel-main
new 17cb3fd9c11 CAMEL-20105: camel-micromemter - Make it easier to configure for camel-main
new 882a2d90c7d CAMEL-20105: camel-micromemter - Make it easier to configure for camel-main
new 636ab5c8c84 CAMEL-20105: camel-micromemter - Make it easier to configure for camel-main
new 4f585e2a4a7 CAMEL-20105: camel-micromemter - Make it easier to configure for camel-main
new a33e11a2bec CAMEL-20105: camel-micromemter - Make it easier to configure for camel-main
new 0daab91b3b9 CAMEL-20105: camel-micromemter - Make it easier to configure for camel-main
new a7ab16f6dcd CAMEL-20105: camel-micromemter - Make it easier to configure for camel-main
new a2e3befa30b CAMEL-20105: camel-micromemter - Make it easier to configure for camel-main
new 6f487542ec5 CAMEL-20105: camel-micromemter - Make it easier to configure for camel-main
new ba22ceeff9a Upgrade to jandex 3.1.5
new 222300e9087 CAMEL-20105: camel-micromemter - Make it easier to configure for camel-main
new 659ab200ff3 CAMEL-20105: camel-micromemter - Make it easier to configure for camel-main
new 5e5a98c6947 CAMEL-20105: camel-micromemter - Make it easier to configure for camel-main
The 16 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(camel) 02/16: CAMEL-20105: camel-micromemter - Make it easier to configure for camel-main
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch mm
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 4990669db6ef3a3ad3ebcb27f842331886f65692
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Nov 15 20:32:16 2023 +0100
CAMEL-20105: camel-micromemter - Make it easier to configure for camel-main
---
.../main/LraConfigurationPropertiesConfigurer.java | 6 ++++++
.../MetricsConfigurationPropertiesConfigurer.java | 6 ++++++
.../main/OtelConfigurationPropertiesConfigurer.java | 6 ++++++
.../META-INF/camel-main-configuration-metadata.json | 3 +++
core/camel-main/src/main/docs/main.adoc | 9 ++++++---
.../camel/main/LraConfigurationProperties.java | 21 +++++++++++++++++++++
.../camel/main/MetricsConfigurationProperties.java | 20 ++++++++++++++++++++
.../camel/main/OtelConfigurationProperties.java | 20 ++++++++++++++++++++
8 files changed, 88 insertions(+), 3 deletions(-)
diff --git a/core/camel-main/src/generated/java/org/apache/camel/main/LraConfigurationPropertiesConfigurer.java b/core/camel-main/src/generated/java/org/apache/camel/main/LraConfigurationPropertiesConfigurer.java
index 106befdd04b..e34dc0a7610 100644
--- a/core/camel-main/src/generated/java/org/apache/camel/main/LraConfigurationPropertiesConfigurer.java
+++ b/core/camel-main/src/generated/java/org/apache/camel/main/LraConfigurationPropertiesConfigurer.java
@@ -25,6 +25,8 @@ public class LraConfigurationPropertiesConfigurer extends org.apache.camel.suppo
case "CoordinatorContextPath": target.setCoordinatorContextPath(property(camelContext, java.lang.String.class, value)); return true;
case "coordinatorurl":
case "CoordinatorUrl": target.setCoordinatorUrl(property(camelContext, java.lang.String.class, value)); return true;
+ case "enabled":
+ case "Enabled": target.setEnabled(property(camelContext, boolean.class, value)); return true;
case "localparticipantcontextpath":
case "LocalParticipantContextPath": target.setLocalParticipantContextPath(property(camelContext, java.lang.String.class, value)); return true;
case "localparticipanturl":
@@ -40,6 +42,8 @@ public class LraConfigurationPropertiesConfigurer extends org.apache.camel.suppo
case "CoordinatorContextPath": return java.lang.String.class;
case "coordinatorurl":
case "CoordinatorUrl": return java.lang.String.class;
+ case "enabled":
+ case "Enabled": return boolean.class;
case "localparticipantcontextpath":
case "LocalParticipantContextPath": return java.lang.String.class;
case "localparticipanturl":
@@ -56,6 +60,8 @@ public class LraConfigurationPropertiesConfigurer extends org.apache.camel.suppo
case "CoordinatorContextPath": return target.getCoordinatorContextPath();
case "coordinatorurl":
case "CoordinatorUrl": return target.getCoordinatorUrl();
+ case "enabled":
+ case "Enabled": return target.isEnabled();
case "localparticipantcontextpath":
case "LocalParticipantContextPath": return target.getLocalParticipantContextPath();
case "localparticipanturl":
diff --git a/core/camel-main/src/generated/java/org/apache/camel/main/MetricsConfigurationPropertiesConfigurer.java b/core/camel-main/src/generated/java/org/apache/camel/main/MetricsConfigurationPropertiesConfigurer.java
index e81062ff0eb..a20fbbf666e 100644
--- a/core/camel-main/src/generated/java/org/apache/camel/main/MetricsConfigurationPropertiesConfigurer.java
+++ b/core/camel-main/src/generated/java/org/apache/camel/main/MetricsConfigurationPropertiesConfigurer.java
@@ -29,6 +29,8 @@ public class MetricsConfigurationPropertiesConfigurer extends org.apache.camel.s
case "EnableRouteEventNotifier": target.setEnableRouteEventNotifier(property(camelContext, boolean.class, value)); return true;
case "enableroutepolicy":
case "EnableRoutePolicy": target.setEnableRoutePolicy(property(camelContext, boolean.class, value)); return true;
+ case "enabled":
+ case "Enabled": target.setEnabled(property(camelContext, boolean.class, value)); return true;
default: return false;
}
}
@@ -44,6 +46,8 @@ public class MetricsConfigurationPropertiesConfigurer extends org.apache.camel.s
case "EnableRouteEventNotifier": return boolean.class;
case "enableroutepolicy":
case "EnableRoutePolicy": return boolean.class;
+ case "enabled":
+ case "Enabled": return boolean.class;
default: return null;
}
}
@@ -60,6 +64,8 @@ public class MetricsConfigurationPropertiesConfigurer extends org.apache.camel.s
case "EnableRouteEventNotifier": return target.isEnableRouteEventNotifier();
case "enableroutepolicy":
case "EnableRoutePolicy": return target.isEnableRoutePolicy();
+ case "enabled":
+ case "Enabled": return target.isEnabled();
default: return null;
}
}
diff --git a/core/camel-main/src/generated/java/org/apache/camel/main/OtelConfigurationPropertiesConfigurer.java b/core/camel-main/src/generated/java/org/apache/camel/main/OtelConfigurationPropertiesConfigurer.java
index 2cd0234490c..c035d6aab7c 100644
--- a/core/camel-main/src/generated/java/org/apache/camel/main/OtelConfigurationPropertiesConfigurer.java
+++ b/core/camel-main/src/generated/java/org/apache/camel/main/OtelConfigurationPropertiesConfigurer.java
@@ -21,6 +21,8 @@ public class OtelConfigurationPropertiesConfigurer extends org.apache.camel.supp
public boolean configure(CamelContext camelContext, Object obj, String name, Object value, boolean ignoreCase) {
org.apache.camel.main.OtelConfigurationProperties target = (org.apache.camel.main.OtelConfigurationProperties) obj;
switch (ignoreCase ? name.toLowerCase() : name) {
+ case "enabled":
+ case "Enabled": target.setEnabled(property(camelContext, boolean.class, value)); return true;
case "encoding":
case "Encoding": target.setEncoding(property(camelContext, boolean.class, value)); return true;
case "excludepatterns":
@@ -34,6 +36,8 @@ public class OtelConfigurationPropertiesConfigurer extends org.apache.camel.supp
@Override
public Class<?> getOptionType(String name, boolean ignoreCase) {
switch (ignoreCase ? name.toLowerCase() : name) {
+ case "enabled":
+ case "Enabled": return boolean.class;
case "encoding":
case "Encoding": return boolean.class;
case "excludepatterns":
@@ -48,6 +52,8 @@ public class OtelConfigurationPropertiesConfigurer extends org.apache.camel.supp
public Object getOptionValue(Object obj, String name, boolean ignoreCase) {
org.apache.camel.main.OtelConfigurationProperties target = (org.apache.camel.main.OtelConfigurationProperties) obj;
switch (ignoreCase ? name.toLowerCase() : name) {
+ case "enabled":
+ case "Enabled": return target.isEnabled();
case "encoding":
case "Encoding": return target.isEncoding();
case "excludepatterns":
diff --git a/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json b/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json
index d5a1d229594..5521078c575 100644
--- a/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json
+++ b/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json
@@ -177,12 +177,15 @@
{ "name": "camel.health.routesEnabled", "description": "Whether routes health check is enabled", "sourceType": "org.apache.camel.main.HealthConfigurationProperties", "type": "boolean", "javaType": "java.lang.Boolean", "defaultValue": true },
{ "name": "camel.lra.coordinatorContextPath", "description": "The context-path for the LRA coordinator. Is default \/lra-coordinator", "sourceType": "org.apache.camel.main.LraConfigurationProperties", "type": "string", "javaType": "java.lang.String", "defaultValue": "\/lra-coordinator" },
{ "name": "camel.lra.coordinatorUrl", "description": "The URL for the LRA coordinator service that orchestrates the transactions", "sourceType": "org.apache.camel.main.LraConfigurationProperties", "type": "string", "javaType": "java.lang.String" },
+ { "name": "camel.lra.enabled", "description": "To enable Saga LRA", "sourceType": "org.apache.camel.main.LraConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": false },
{ "name": "camel.lra.localParticipantContextPath", "description": "The context-path for the local participant. Is default \/lra-participant", "sourceType": "org.apache.camel.main.LraConfigurationProperties", "type": "string", "javaType": "java.lang.String", "defaultValue": "\/lra-participant" },
{ "name": "camel.lra.localParticipantUrl", "description": "The URL for the local participant", "sourceType": "org.apache.camel.main.LraConfigurationProperties", "type": "string", "javaType": "java.lang.String" },
+ { "name": "camel.metrics.enabled", "description": "To enable Micrometer metrics.", "sourceType": "org.apache.camel.main.MetricsConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
{ "name": "camel.metrics.enableExchangeEventNotifier", "description": "Set whether to enable the MicrometerExchangeEventNotifier for capturing metrics on exchange processing times.", "sourceType": "org.apache.camel.main.MetricsConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": true },
{ "name": "camel.metrics.enableMessageHistory", "description": "Set whether to enable the MicrometerMessageHistoryFactory for capturing metrics on individual route node processing times. Depending on the number of configured route nodes, there is the potential to create a large volume of metrics. Therefore, this option is disabled by default.", "sourceType": "org.apache.camel.main.MetricsConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
{ "name": "camel.metrics.enableRouteEventNotifier", "description": "Set whether to enable the MicrometerRouteEventNotifier for capturing metrics on the total number of routes and total number of routes running.", "sourceType": "org.apache.camel.main.MetricsConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": true },
{ "name": "camel.metrics.enableRoutePolicy", "description": "Set whether to enable the MicrometerRoutePolicyFactory for capturing metrics on route processing times.", "sourceType": "org.apache.camel.main.MetricsConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": true },
+ { "name": "camel.opentelemetry.enabled", "description": "To enable OpenTelemetry", "sourceType": "org.apache.camel.main.OtelConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
{ "name": "camel.opentelemetry.encoding", "description": "Sets whether the header keys need to be encoded (connector specific) or not. The value is a boolean. Dashes need for instances to be encoded for JMS property keys.", "sourceType": "org.apache.camel.main.OtelConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
{ "name": "camel.opentelemetry.excludePatterns", "description": "Adds an exclude pattern that will disable tracing for Camel messages that matches the pattern. Multiple patterns can be separated by comma.", "sourceType": "org.apache.camel.main.OtelConfigurationProperties", "type": "string", "javaType": "java.lang.String" },
{ "name": "camel.opentelemetry.instrumentationName", "description": "A name uniquely identifying the instrumentation scope, such as the instrumentation library, package, or fully qualified class name. Must not be null.", "sourceType": "org.apache.camel.main.OtelConfigurationProperties", "type": "string", "javaType": "java.lang.String", "defaultValue": "camel" },
diff --git a/core/camel-main/src/main/docs/main.adoc b/core/camel-main/src/main/docs/main.adoc
index c855cacb293..9eb1ebfe7a9 100644
--- a/core/camel-main/src/main/docs/main.adoc
+++ b/core/camel-main/src/main/docs/main.adoc
@@ -333,11 +333,12 @@ The camel.vault.azure supports 11 options, which are listed below.
=== Camel OpenTelemtry configurations
-The camel.opentelemetry supports 3 options, which are listed below.
+The camel.opentelemetry supports 4 options, which are listed below.
[width="100%",cols="2,5,^1,2",options="header"]
|===
| Name | Description | Default | Type
+| *camel.opentelemetry.enabled* | To enable OpenTelemetry | false | boolean
| *camel.opentelemetry.encoding* | Sets whether the header keys need to be encoded (connector specific) or not. The value is a boolean. Dashes need for instances to be encoded for JMS property keys. | false | boolean
| *camel.opentelemetry.exclude{zwsp}Patterns* | Adds an exclude pattern that will disable tracing for Camel messages that matches the pattern. Multiple patterns can be separated by comma. | | String
| *{zwsp}camel.opentelemetry.instrumentation{zwsp}Name* | A name uniquely identifying the instrumentation scope, such as the instrumentation library, package, or fully qualified class name. Must not be null. | camel | String
@@ -345,11 +346,12 @@ The camel.opentelemetry supports 3 options, which are listed below.
=== Camel Micrometer Metrics configurations
-The camel.metrics supports 4 options, which are listed below.
+The camel.metrics supports 5 options, which are listed below.
[width="100%",cols="2,5,^1,2",options="header"]
|===
| Name | Description | Default | Type
+| *camel.metrics.enabled* | To enable Micrometer metrics. | false | boolean
| *camel.metrics.enableExchange{zwsp}EventNotifier* | Set whether to enable the MicrometerExchangeEventNotifier for capturing metrics on exchange processing times. | true | boolean
| *camel.metrics.enableMessage{zwsp}History* | Set whether to enable the MicrometerMessageHistoryFactory for capturing metrics on individual route node processing times. Depending on the number of configured route nodes, there is the potential to create a large volume of metrics. Therefore, this option is disabled by default. | false | boolean
| *camel.metrics.enableRouteEvent{zwsp}Notifier* | Set whether to enable the MicrometerRouteEventNotifier for capturing metrics on the total number of routes and total number of routes running. | true | boolean
@@ -409,13 +411,14 @@ The camel.resilience4j supports 20 options, which are listed below.
=== Camel Saga EIP (Long Running Actions) configurations
-The camel.lra supports 4 options, which are listed below.
+The camel.lra supports 5 options, which are listed below.
[width="100%",cols="2,5,^1,2",options="header"]
|===
| Name | Description | Default | Type
| *camel.lra.coordinatorContext{zwsp}Path* | The context-path for the LRA coordinator. Is default /lra-coordinator | /lra-coordinator | String
| *camel.lra.coordinatorUrl* | The URL for the LRA coordinator service that orchestrates the transactions | | String
+| *camel.lra.enabled* | To enable Saga LRA | false | boolean
| *camel.lra.localParticipant{zwsp}ContextPath* | The context-path for the local participant. Is default /lra-participant | /lra-participant | String
| *camel.lra.localParticipantUrl* | The URL for the local participant | | String
|===
diff --git a/core/camel-main/src/main/java/org/apache/camel/main/LraConfigurationProperties.java b/core/camel-main/src/main/java/org/apache/camel/main/LraConfigurationProperties.java
index c0106ddbcac..0246b724b0b 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/LraConfigurationProperties.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/LraConfigurationProperties.java
@@ -28,6 +28,8 @@ public class LraConfigurationProperties implements BootstrapCloseable {
private MainConfigurationProperties parent;
+ @Metadata(defaultValue = "false")
+ private boolean enabled;
private String coordinatorUrl;
@Metadata(defaultValue = "/lra-coordinator")
private String coordinatorContextPath = "/lra-coordinator";
@@ -48,6 +50,17 @@ public class LraConfigurationProperties implements BootstrapCloseable {
parent = null;
}
+ public boolean isEnabled() {
+ return enabled;
+ }
+
+ /**
+ * To enable Saga LRA
+ */
+ public void setEnabled(boolean enabled) {
+ this.enabled = enabled;
+ }
+
public String getCoordinatorUrl() {
return coordinatorUrl;
}
@@ -104,6 +117,14 @@ public class LraConfigurationProperties implements BootstrapCloseable {
return this;
}
+ /**
+ * To enable Saga LRA
+ */
+ public LraConfigurationProperties withEnabled(boolean enabled) {
+ this.enabled = enabled;
+ return this;
+ }
+
/**
* The context-path for the LRA coordinator.
*/
diff --git a/core/camel-main/src/main/java/org/apache/camel/main/MetricsConfigurationProperties.java b/core/camel-main/src/main/java/org/apache/camel/main/MetricsConfigurationProperties.java
index ca54f8122c6..d9985fcf26f 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/MetricsConfigurationProperties.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/MetricsConfigurationProperties.java
@@ -28,6 +28,7 @@ public class MetricsConfigurationProperties implements BootstrapCloseable {
private MainConfigurationProperties parent;
+ private boolean enabled;
@Metadata(defaultValue = "true")
private boolean enableRoutePolicy = true;
private boolean enableMessageHistory;
@@ -44,6 +45,17 @@ public class MetricsConfigurationProperties implements BootstrapCloseable {
return parent;
}
+ public boolean isEnabled() {
+ return enabled;
+ }
+
+ /**
+ * To enable Micrometer metrics.
+ */
+ public void setEnabled(boolean enabled) {
+ this.enabled = enabled;
+ }
+
public boolean isEnableRoutePolicy() {
return enableRoutePolicy;
}
@@ -106,6 +118,14 @@ public class MetricsConfigurationProperties implements BootstrapCloseable {
return this;
}
+ /**
+ * To enable Micrometer metrics.
+ */
+ public MetricsConfigurationProperties withEnabled(boolean enabled) {
+ this.enabled = enabled;
+ return this;
+ }
+
/**
* Set whether to enable the MicrometerMessageHistoryFactory for capturing metrics on individual route node
* processing times.
diff --git a/core/camel-main/src/main/java/org/apache/camel/main/OtelConfigurationProperties.java b/core/camel-main/src/main/java/org/apache/camel/main/OtelConfigurationProperties.java
index a41c23a1694..567356d5d02 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/OtelConfigurationProperties.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/OtelConfigurationProperties.java
@@ -28,6 +28,7 @@ public class OtelConfigurationProperties implements BootstrapCloseable {
private MainConfigurationProperties parent;
+ private boolean enabled;
@Metadata(defaultValue = "camel", required = true)
private String instrumentationName = "camel";
private boolean encoding;
@@ -46,6 +47,17 @@ public class OtelConfigurationProperties implements BootstrapCloseable {
parent = null;
}
+ public boolean isEnabled() {
+ return enabled;
+ }
+
+ /**
+ * To enable OpenTelemetry
+ */
+ public void setEnabled(boolean enabled) {
+ this.enabled = enabled;
+ }
+
public String getInstrumentationName() {
return instrumentationName;
}
@@ -91,6 +103,14 @@ public class OtelConfigurationProperties implements BootstrapCloseable {
return this;
}
+ /**
+ * To enable OpenTelemetry
+ */
+ public OtelConfigurationProperties withEnabled(boolean enabled) {
+ this.enabled = enabled;
+ return this;
+ }
+
/**
* Sets whether the header keys need to be encoded (connector specific) or not. The value is a boolean. Dashes need
* for instances to be encoded for JMS property keys.
(camel) 10/16: CAMEL-20105: camel-micromemter - Make it easier to configure for camel-main
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch mm
in repository https://gitbox.apache.org/repos/asf/camel.git
commit a7ab16f6dcdef445c464987b8fe02bfb6eb1d85f
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Thu Nov 16 09:05:35 2023 +0100
CAMEL-20105: camel-micromemter - Make it easier to configure for camel-main
---
.../org/apache/camel/catalog/others/micrometer-prometheus.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/others/micrometer-prometheus.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/others/micrometer-prometheus.json
index de860450126..429ab2db753 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/others/micrometer-prometheus.json
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/others/micrometer-prometheus.json
@@ -3,7 +3,7 @@
"kind": "other",
"name": "micrometer-prometheus",
"title": "Micrometer Prometheus",
- "description": "Camel Micrometer Prometheus",
+ "description": "Camel Micrometer Prometheus for Camel Main",
"deprecated": false,
"firstVersion": "4.3.0",
"supportLevel": "Preview",
(camel) 12/16: CAMEL-20105: camel-micromemter - Make it easier to configure for camel-main
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch mm
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 6f487542ec592c7efd4749780e461c093d6ca3ec
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Thu Nov 16 09:32:36 2023 +0100
CAMEL-20105: camel-micromemter - Make it easier to configure for camel-main
---
.../main/camel-main-configuration-metadata.json | 1 +
.../prometheus/MicrometerPrometheusConfigurer.java | 6 ++++
.../prometheus/MicrometerPrometheus.java | 33 +++++++++++++++++++---
.../MetricsConfigurationPropertiesConfigurer.java | 6 ++++
.../camel-main-configuration-metadata.json | 1 +
core/camel-main/src/main/docs/main.adoc | 3 +-
.../camel/main/MetricsConfigurationProperties.java | 28 ++++++++++++++++++
7 files changed, 73 insertions(+), 5 deletions(-)
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/camel-main-configuration-metadata.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/camel-main-configuration-metadata.json
index 92bef5801ed..22167f65ed6 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/camel-main-configuration-metadata.json
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/camel-main-configuration-metadata.json
@@ -185,6 +185,7 @@
{ "name": "camel.metrics.enableMessageHistory", "description": "Set whether to enable the MicrometerMessageHistoryFactory for capturing metrics on individual route node processing times. Depending on the number of configured route nodes, there is the potential to create a large volume of metrics. Therefore, this option is disabled by default.", "sourceType": "org.apache.camel.main.MetricsConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
{ "name": "camel.metrics.enableRouteEventNotifier", "description": "Set whether to enable the MicrometerRouteEventNotifier for capturing metrics on the total number of routes and total number of routes running.", "sourceType": "org.apache.camel.main.MetricsConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": true },
{ "name": "camel.metrics.enableRoutePolicy", "description": "Set whether to enable the MicrometerRoutePolicyFactory for capturing metrics on route processing times.", "sourceType": "org.apache.camel.main.MetricsConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": true },
+ { "name": "camel.metrics.textFormatVersion", "description": "The text-format version to use with Prometheus scraping. 0.0.4 = text\/plain; version=0.0.4; charset=utf-8 1.0.0 = application\/openmetrics-text; version=1.0.0; charset=utf-8", "sourceType": "org.apache.camel.main.MetricsConfigurationProperties", "type": "string", "javaType": "java.lang.String", "defaultValue": "0.0.4", "enum": [ "0.0.4", "1.0.0" ] },
{ "name": "camel.opentelemetry.enabled", "description": "To enable OpenTelemetry", "sourceType": "org.apache.camel.main.OtelConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
{ "name": "camel.opentelemetry.encoding", "description": "Sets whether the header keys need to be encoded (connector specific) or not. The value is a boolean. Dashes need for instances to be encoded for JMS property keys.", "sourceType": "org.apache.camel.main.OtelConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
{ "name": "camel.opentelemetry.excludePatterns", "description": "Adds an exclude pattern that will disable tracing for Camel messages that matches the pattern. Multiple patterns can be separated by comma.", "sourceType": "org.apache.camel.main.OtelConfigurationProperties", "type": "string", "javaType": "java.lang.String" },
diff --git a/components/camel-micrometer-prometheus/src/generated/java/org/apache/camel/component/micrometer/prometheus/MicrometerPrometheusConfigurer.java b/components/camel-micrometer-prometheus/src/generated/java/org/apache/camel/component/micrometer/prometheus/MicrometerPrometheusConfigurer.java
index 2f934e1d64e..abad014040c 100644
--- a/components/camel-micrometer-prometheus/src/generated/java/org/apache/camel/component/micrometer/prometheus/MicrometerPrometheusConfigurer.java
+++ b/components/camel-micrometer-prometheus/src/generated/java/org/apache/camel/component/micrometer/prometheus/MicrometerPrometheusConfigurer.java
@@ -31,6 +31,8 @@ public class MicrometerPrometheusConfigurer extends org.apache.camel.support.com
case "EnableRouteEventNotifier": target.setEnableRouteEventNotifier(property(camelContext, boolean.class, value)); return true;
case "enableroutepolicy":
case "EnableRoutePolicy": target.setEnableRoutePolicy(property(camelContext, boolean.class, value)); return true;
+ case "textformatversion":
+ case "TextFormatVersion": target.setTextFormatVersion(property(camelContext, java.lang.String.class, value)); return true;
default: return false;
}
}
@@ -48,6 +50,8 @@ public class MicrometerPrometheusConfigurer extends org.apache.camel.support.com
case "EnableRouteEventNotifier": return boolean.class;
case "enableroutepolicy":
case "EnableRoutePolicy": return boolean.class;
+ case "textformatversion":
+ case "TextFormatVersion": return java.lang.String.class;
default: return null;
}
}
@@ -66,6 +70,8 @@ public class MicrometerPrometheusConfigurer extends org.apache.camel.support.com
case "EnableRouteEventNotifier": return target.isEnableRouteEventNotifier();
case "enableroutepolicy":
case "EnableRoutePolicy": return target.isEnableRoutePolicy();
+ case "textformatversion":
+ case "TextFormatVersion": return target.getTextFormatVersion();
default: return null;
}
}
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 61efbba632b..1f20b3e3841 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
@@ -18,6 +18,7 @@ package org.apache.camel.component.micrometer.prometheus;
import io.micrometer.prometheus.PrometheusConfig;
import io.micrometer.prometheus.PrometheusMeterRegistry;
+import io.prometheus.client.exporter.common.TextFormat;
import io.vertx.core.Handler;
import io.vertx.core.http.HttpMethod;
import io.vertx.ext.web.Route;
@@ -53,7 +54,6 @@ public class MicrometerPrometheus extends ServiceSupport implements CamelMetrics
private VertxPlatformHttpRouter router;
private PlatformHttpComponent platformHttpComponent;
- // TODO: 0.0.4 or 1.0.0 text format
// TODO: option include JVM metrics
// TODO: option include platform-http metrics
// TODO: include easily with jbang
@@ -70,6 +70,8 @@ public class MicrometerPrometheus extends ServiceSupport implements CamelMetrics
private boolean enableExchangeEventNotifier = true;
@Metadata(defaultValue = "true")
private boolean enableRouteEventNotifier = true;
+ @Metadata(defaultValue = "0.0.4", enums = "0.0.4,1.0.0")
+ private String textFormatVersion = "0.0.4";
@Override
public CamelContext getCamelContext() {
@@ -130,6 +132,20 @@ public class MicrometerPrometheus extends ServiceSupport implements CamelMetrics
this.enableRouteEventNotifier = enableRouteEventNotifier;
}
+ public String getTextFormatVersion() {
+ return textFormatVersion;
+ }
+
+ /**
+ * The text-format version to use with Prometheus scraping.
+ *
+ * 0.0.4 = text/plain; version=0.0.4; charset=utf-8
+ * 1.0.0 = application/openmetrics-text; version=1.0.0; charset=utf-8
+ */
+ public void setTextFormatVersion(String textFormatVersion) {
+ this.textFormatVersion = textFormatVersion;
+ }
+
@Override
protected void doStart() throws Exception {
super.doStart();
@@ -177,13 +193,22 @@ public class MicrometerPrometheus extends ServiceSupport implements CamelMetrics
protected void setupHttpScraper() {
Route metrics = router.route("/q/metrics");
metrics.method(HttpMethod.GET);
- metrics.produces("text/plain;version=0.0.4;charset=utf-8");
+
+ final String format = "0.0.4".equals(textFormatVersion) ? TextFormat.CONTENT_TYPE_004 : TextFormat.CONTENT_TYPE_OPENMETRICS_100;
+ metrics.produces(format);
Handler<RoutingContext> handler = new Handler<RoutingContext>() {
@Override
public void handle(RoutingContext ctx) {
- ctx.response().putHeader("content-type", "text/plain;version=0.0.4;charset=utf-8");
- String data = meterRegistry.scrape();
+ String ct = format;
+ // the client may ask for version 1.0.0 via accept header
+ String ah = ctx.request().getHeader("Accept");
+ if (ah != null && ah.contains("application/openmetrics-text")) {
+ ct = TextFormat.chooseContentType(ah);
+ }
+
+ ctx.response().putHeader("Content-Type", ct);
+ String data = meterRegistry.scrape(ct);
ctx.end(data);
}
};
diff --git a/core/camel-main/src/generated/java/org/apache/camel/main/MetricsConfigurationPropertiesConfigurer.java b/core/camel-main/src/generated/java/org/apache/camel/main/MetricsConfigurationPropertiesConfigurer.java
index a20fbbf666e..ed323ad35fd 100644
--- a/core/camel-main/src/generated/java/org/apache/camel/main/MetricsConfigurationPropertiesConfigurer.java
+++ b/core/camel-main/src/generated/java/org/apache/camel/main/MetricsConfigurationPropertiesConfigurer.java
@@ -31,6 +31,8 @@ public class MetricsConfigurationPropertiesConfigurer extends org.apache.camel.s
case "EnableRoutePolicy": target.setEnableRoutePolicy(property(camelContext, boolean.class, value)); return true;
case "enabled":
case "Enabled": target.setEnabled(property(camelContext, boolean.class, value)); return true;
+ case "textformatversion":
+ case "TextFormatVersion": target.setTextFormatVersion(property(camelContext, java.lang.String.class, value)); return true;
default: return false;
}
}
@@ -48,6 +50,8 @@ public class MetricsConfigurationPropertiesConfigurer extends org.apache.camel.s
case "EnableRoutePolicy": return boolean.class;
case "enabled":
case "Enabled": return boolean.class;
+ case "textformatversion":
+ case "TextFormatVersion": return java.lang.String.class;
default: return null;
}
}
@@ -66,6 +70,8 @@ public class MetricsConfigurationPropertiesConfigurer extends org.apache.camel.s
case "EnableRoutePolicy": return target.isEnableRoutePolicy();
case "enabled":
case "Enabled": return target.isEnabled();
+ case "textformatversion":
+ case "TextFormatVersion": return target.getTextFormatVersion();
default: return null;
}
}
diff --git a/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json b/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json
index 92bef5801ed..22167f65ed6 100644
--- a/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json
+++ b/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json
@@ -185,6 +185,7 @@
{ "name": "camel.metrics.enableMessageHistory", "description": "Set whether to enable the MicrometerMessageHistoryFactory for capturing metrics on individual route node processing times. Depending on the number of configured route nodes, there is the potential to create a large volume of metrics. Therefore, this option is disabled by default.", "sourceType": "org.apache.camel.main.MetricsConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
{ "name": "camel.metrics.enableRouteEventNotifier", "description": "Set whether to enable the MicrometerRouteEventNotifier for capturing metrics on the total number of routes and total number of routes running.", "sourceType": "org.apache.camel.main.MetricsConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": true },
{ "name": "camel.metrics.enableRoutePolicy", "description": "Set whether to enable the MicrometerRoutePolicyFactory for capturing metrics on route processing times.", "sourceType": "org.apache.camel.main.MetricsConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": true },
+ { "name": "camel.metrics.textFormatVersion", "description": "The text-format version to use with Prometheus scraping. 0.0.4 = text\/plain; version=0.0.4; charset=utf-8 1.0.0 = application\/openmetrics-text; version=1.0.0; charset=utf-8", "sourceType": "org.apache.camel.main.MetricsConfigurationProperties", "type": "string", "javaType": "java.lang.String", "defaultValue": "0.0.4", "enum": [ "0.0.4", "1.0.0" ] },
{ "name": "camel.opentelemetry.enabled", "description": "To enable OpenTelemetry", "sourceType": "org.apache.camel.main.OtelConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
{ "name": "camel.opentelemetry.encoding", "description": "Sets whether the header keys need to be encoded (connector specific) or not. The value is a boolean. Dashes need for instances to be encoded for JMS property keys.", "sourceType": "org.apache.camel.main.OtelConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
{ "name": "camel.opentelemetry.excludePatterns", "description": "Adds an exclude pattern that will disable tracing for Camel messages that matches the pattern. Multiple patterns can be separated by comma.", "sourceType": "org.apache.camel.main.OtelConfigurationProperties", "type": "string", "javaType": "java.lang.String" },
diff --git a/core/camel-main/src/main/docs/main.adoc b/core/camel-main/src/main/docs/main.adoc
index 22cbfb5a276..426dff178b1 100644
--- a/core/camel-main/src/main/docs/main.adoc
+++ b/core/camel-main/src/main/docs/main.adoc
@@ -347,7 +347,7 @@ The camel.opentelemetry supports 4 options, which are listed below.
=== Camel Micrometer Metrics configurations
-The camel.metrics supports 5 options, which are listed below.
+The camel.metrics supports 6 options, which are listed below.
[width="100%",cols="2,5,^1,2",options="header"]
|===
@@ -357,6 +357,7 @@ The camel.metrics supports 5 options, which are listed below.
| *camel.metrics.enableMessage{zwsp}History* | Set whether to enable the MicrometerMessageHistoryFactory for capturing metrics on individual route node processing times. Depending on the number of configured route nodes, there is the potential to create a large volume of metrics. Therefore, this option is disabled by default. | false | boolean
| *camel.metrics.enableRouteEvent{zwsp}Notifier* | Set whether to enable the MicrometerRouteEventNotifier for capturing metrics on the total number of routes and total number of routes running. | true | boolean
| *camel.metrics.enableRoute{zwsp}Policy* | Set whether to enable the MicrometerRoutePolicyFactory for capturing metrics on route processing times. | true | boolean
+| *camel.metrics.textFormat{zwsp}Version* | The text-format version to use with Prometheus scraping. 0.0.4 = text/plain; version=0.0.4; charset=utf-8 1.0.0 = application/openmetrics-text; version=1.0.0; charset=utf-8 | 0.0.4 | String
|===
diff --git a/core/camel-main/src/main/java/org/apache/camel/main/MetricsConfigurationProperties.java b/core/camel-main/src/main/java/org/apache/camel/main/MetricsConfigurationProperties.java
index d9985fcf26f..dd55c2951c3 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/MetricsConfigurationProperties.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/MetricsConfigurationProperties.java
@@ -36,6 +36,8 @@ public class MetricsConfigurationProperties implements BootstrapCloseable {
private boolean enableExchangeEventNotifier = true;
@Metadata(defaultValue = "true")
private boolean enableRouteEventNotifier = true;
+ @Metadata(defaultValue = "0.0.4", enums = "0.0.4,1.0.0")
+ private String textFormatVersion = "0.0.4";
public MetricsConfigurationProperties(MainConfigurationProperties parent) {
this.parent = parent;
@@ -105,6 +107,20 @@ public class MetricsConfigurationProperties implements BootstrapCloseable {
this.enableRouteEventNotifier = enableRouteEventNotifier;
}
+ public String getTextFormatVersion() {
+ return textFormatVersion;
+ }
+
+ /**
+ * The text-format version to use with Prometheus scraping.
+ *
+ * 0.0.4 = text/plain; version=0.0.4; charset=utf-8
+ * 1.0.0 = application/openmetrics-text; version=1.0.0; charset=utf-8
+ */
+ public void setTextFormatVersion(String textFormatVersion) {
+ this.textFormatVersion = textFormatVersion;
+ }
+
@Override
public void close() {
parent = null;
@@ -155,4 +171,16 @@ public class MetricsConfigurationProperties implements BootstrapCloseable {
return this;
}
+ /**
+ * The text-format version to use with Prometheus scraping.
+ *
+ * 0.0.4 = text/plain; version=0.0.4; charset=utf-8
+ * 1.0.0 = application/openmetrics-text; version=1.0.0; charset=utf-8
+ */
+ public MetricsConfigurationProperties withTextFormatVersion(String textFormatVersion) {
+ this.textFormatVersion = textFormatVersion;
+ return this;
+ }
+
+
}
(camel) 16/16: CAMEL-20105: camel-micromemter - Make it easier to configure for camel-main
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch mm
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 5e5a98c6947d55f0b77e71cfd379a6c6f1340038
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Thu Nov 16 15:37:57 2023 +0100
CAMEL-20105: camel-micromemter - Make it easier to configure for camel-main
---
.../src/main/docs/micrometer-prometheus.adoc | 31 ++++++++++++++++++++++
.../prometheus/MicrometerPrometheus.java | 3 ---
.../src/test/resources/log4j2.properties | 28 -------------------
3 files changed, 31 insertions(+), 31 deletions(-)
diff --git a/components/camel-micrometer-prometheus/src/main/docs/micrometer-prometheus.adoc b/components/camel-micrometer-prometheus/src/main/docs/micrometer-prometheus.adoc
new file mode 100644
index 00000000000..e558d9901a3
--- /dev/null
+++ b/components/camel-micrometer-prometheus/src/main/docs/micrometer-prometheus.adoc
@@ -0,0 +1,31 @@
+= Micrometer Prometheus Component
+:doctitle: Micrometer Prometheus
+:shortname: micrometer-prometheus
+:artifactid: camel-micrometer-prometheus
+:description: Camel Micrometer Prometheus for Camel Main
+:since: 4.3
+:supportlevel: Preview
+:tabs-sync-option:
+
+*Since Camel {since}*
+
+The camel-micrometer-prometheus is used for running Camel standalone (camel-main) and integrate with Micrometer Prometheus Registry.
+
+== Auto-detection from classpath
+
+To use this implementation all you need to do is to add the `camel-micrometer-prometheus` dependency to the classpath,
+and turn on metrics in `application.properties` such as:
+
+[source,properties]
+----
+# enable HTTP server with metrics
+camel.server.enabled=true
+camel.server.metricsEnabled=true
+
+# turn on micrometer metrics
+camel.metrics.enabled=true
+# include more camel details
+camel.metrics.enableMessageHistory=true
+# include additional out-of-the-box micrometer metrics for cpu, jvm and used file descriptors
+camel.metrics.binders=processor,jvm-info,file-descriptor
+----
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 cb04572ad60..a37ad11185f 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
@@ -70,9 +70,6 @@ public class MicrometerPrometheus extends ServiceSupport implements CamelMetrics
private VertxPlatformHttpRouter router;
private PlatformHttpComponent platformHttpComponent;
- // TODO: include easily with jbang
- // TODO: docs
-
private CamelContext camelContext;
private final PrometheusMeterRegistry meterRegistry = new PrometheusMeterRegistry(PrometheusConfig.DEFAULT);
private final Set<MeterBinder> createdBinders = new HashSet<>();
diff --git a/components/camel-micrometer-prometheus/src/test/resources/log4j2.properties b/components/camel-micrometer-prometheus/src/test/resources/log4j2.properties
deleted file mode 100644
index f24ae625ca1..00000000000
--- a/components/camel-micrometer-prometheus/src/test/resources/log4j2.properties
+++ /dev/null
@@ -1,28 +0,0 @@
-## ---------------------------------------------------------------------------
-## 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-test-micrometer-prometheus.log
-appender.file.layout.type = PatternLayout
-appender.file.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n
-appender.out.type = Console
-appender.out.name = out
-appender.out.layout.type = PatternLayout
-appender.out.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n
-rootLogger.level = INFO
-rootLogger.appenderRef.file.ref = file
(camel) 08/16: CAMEL-20105: camel-micromemter - Make it easier to configure for camel-main
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch mm
in repository https://gitbox.apache.org/repos/asf/camel.git
commit a33e11a2bec5952fc7e6df0a14250c645e5a9640
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Nov 15 21:38:12 2023 +0100
CAMEL-20105: camel-micromemter - Make it easier to configure for camel-main
---
.../camel/component/micrometer/prometheus/MicrometerPrometheus.java | 2 +-
1 file changed, 1 insertion(+), 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 f909665a4d6..ad07eee99ae 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
@@ -182,7 +182,7 @@ public class MicrometerPrometheus extends ServiceSupport implements CamelMetrics
public void handle(RoutingContext ctx) {
ctx.response().putHeader("content-type", "text/plain;version=0.0.4;charset=utf-8");
String data = meterRegistry.scrape();
- ctx.response().write(data);
+ ctx.end(data);
}
};
(camel) 15/16: CAMEL-20105: camel-micromemter - Make it easier to configure for camel-main
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch mm
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 659ab200ff35b6bd3da6f507b6241329ca0630fa
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Thu Nov 16 15:11:51 2023 +0100
CAMEL-20105: camel-micromemter - Make it easier to configure for camel-main
---
.../org/apache/camel/catalog/main/camel-main-configuration-metadata.json | 1 +
1 file changed, 1 insertion(+)
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/camel-main-configuration-metadata.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/camel-main-configuration-metadata.json
index 22167f65ed6..b394013bf78 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/camel-main-configuration-metadata.json
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/camel-main-configuration-metadata.json
@@ -180,6 +180,7 @@
{ "name": "camel.lra.enabled", "description": "To enable Saga LRA", "sourceType": "org.apache.camel.main.LraConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": false },
{ "name": "camel.lra.localParticipantContextPath", "description": "The context-path for the local participant. Is default \/lra-participant", "sourceType": "org.apache.camel.main.LraConfigurationProperties", "type": "string", "javaType": "java.lang.String", "defaultValue": "\/lra-participant" },
{ "name": "camel.lra.localParticipantUrl", "description": "The URL for the local participant", "sourceType": "org.apache.camel.main.LraConfigurationProperties", "type": "string", "javaType": "java.lang.String" },
+ { "name": "camel.metrics.binders", "description": "Additional Micrometer binders to include such as jvm-memory, processor, jvm-thread, and so forth. Multiple binders can be separated by comma.", "sourceType": "org.apache.camel.main.MetricsConfigurationProperties", "type": "string", "javaType": "java.lang.String" },
{ "name": "camel.metrics.enabled", "description": "To enable Micrometer metrics.", "sourceType": "org.apache.camel.main.MetricsConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
{ "name": "camel.metrics.enableExchangeEventNotifier", "description": "Set whether to enable the MicrometerExchangeEventNotifier for capturing metrics on exchange processing times.", "sourceType": "org.apache.camel.main.MetricsConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": true },
{ "name": "camel.metrics.enableMessageHistory", "description": "Set whether to enable the MicrometerMessageHistoryFactory for capturing metrics on individual route node processing times. Depending on the number of configured route nodes, there is the potential to create a large volume of metrics. Therefore, this option is disabled by default.", "sourceType": "org.apache.camel.main.MetricsConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
(camel) 05/16: CAMEL-20105: camel-micromemter - Make it easier to configure for camel-main
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch mm
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 882a2d90c7deef4967ddde66b17ce57fa57a197d
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Nov 15 21:10:06 2023 +0100
CAMEL-20105: camel-micromemter - Make it easier to configure for camel-main
---
bom/camel-bom/pom.xml | 5 +++++
.../catalog/main/camel-main-configuration-metadata.json | 8 ++++++++
.../resources/org/apache/camel/catalog/others.properties | 1 +
.../apache/camel/catalog/others/micrometer-prometheus.json | 14 ++++++++++++++
4 files changed, 28 insertions(+)
diff --git a/bom/camel-bom/pom.xml b/bom/camel-bom/pom.xml
index b45cae86a79..9a4412c8125 100644
--- a/bom/camel-bom/pom.xml
+++ b/bom/camel-bom/pom.xml
@@ -1347,6 +1347,11 @@
<artifactId>camel-micrometer</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-micrometer-prometheus</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-microprofile-config</artifactId>
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/camel-main-configuration-metadata.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/camel-main-configuration-metadata.json
index 3a89ff173c1..5521078c575 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/camel-main-configuration-metadata.json
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/camel-main-configuration-metadata.json
@@ -11,6 +11,7 @@
{ "name": "camel.vault.gcp", "description": "Camel GCP Vault configurations", "sourceType": "org.apache.camel.vault.GcpVaultConfiguration" },
{ "name": "camel.vault.azure", "description": "Camel Azure Key Vault configurations", "sourceType": "org.apache.camel.vault.AzureVaultConfiguration" },
{ "name": "camel.opentelemetry", "description": "Camel OpenTelemtry configurations", "sourceType": "org.apache.camel.main.OtelConfigurationProperties" },
+ { "name": "camel.metrics", "description": "Camel Micrometer Metrics configurations", "sourceType": "org.apache.camel.main.MetricsConfigurationProperties" },
{ "name": "camel.faulttolerance", "description": "Fault Tolerance EIP Circuit Breaker configurations", "sourceType": "org.apache.camel.main.FaultToleranceConfigurationProperties" },
{ "name": "camel.resilience4j", "description": "Resilience4j EIP Circuit Breaker configurations", "sourceType": "org.apache.camel.main.Resilience4jConfigurationProperties" },
{ "name": "camel.lra", "description": "Camel Saga EIP (Long Running Actions) configurations", "sourceType": "org.apache.camel.main.LraConfigurationProperties" }
@@ -176,8 +177,15 @@
{ "name": "camel.health.routesEnabled", "description": "Whether routes health check is enabled", "sourceType": "org.apache.camel.main.HealthConfigurationProperties", "type": "boolean", "javaType": "java.lang.Boolean", "defaultValue": true },
{ "name": "camel.lra.coordinatorContextPath", "description": "The context-path for the LRA coordinator. Is default \/lra-coordinator", "sourceType": "org.apache.camel.main.LraConfigurationProperties", "type": "string", "javaType": "java.lang.String", "defaultValue": "\/lra-coordinator" },
{ "name": "camel.lra.coordinatorUrl", "description": "The URL for the LRA coordinator service that orchestrates the transactions", "sourceType": "org.apache.camel.main.LraConfigurationProperties", "type": "string", "javaType": "java.lang.String" },
+ { "name": "camel.lra.enabled", "description": "To enable Saga LRA", "sourceType": "org.apache.camel.main.LraConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": false },
{ "name": "camel.lra.localParticipantContextPath", "description": "The context-path for the local participant. Is default \/lra-participant", "sourceType": "org.apache.camel.main.LraConfigurationProperties", "type": "string", "javaType": "java.lang.String", "defaultValue": "\/lra-participant" },
{ "name": "camel.lra.localParticipantUrl", "description": "The URL for the local participant", "sourceType": "org.apache.camel.main.LraConfigurationProperties", "type": "string", "javaType": "java.lang.String" },
+ { "name": "camel.metrics.enabled", "description": "To enable Micrometer metrics.", "sourceType": "org.apache.camel.main.MetricsConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
+ { "name": "camel.metrics.enableExchangeEventNotifier", "description": "Set whether to enable the MicrometerExchangeEventNotifier for capturing metrics on exchange processing times.", "sourceType": "org.apache.camel.main.MetricsConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": true },
+ { "name": "camel.metrics.enableMessageHistory", "description": "Set whether to enable the MicrometerMessageHistoryFactory for capturing metrics on individual route node processing times. Depending on the number of configured route nodes, there is the potential to create a large volume of metrics. Therefore, this option is disabled by default.", "sourceType": "org.apache.camel.main.MetricsConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
+ { "name": "camel.metrics.enableRouteEventNotifier", "description": "Set whether to enable the MicrometerRouteEventNotifier for capturing metrics on the total number of routes and total number of routes running.", "sourceType": "org.apache.camel.main.MetricsConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": true },
+ { "name": "camel.metrics.enableRoutePolicy", "description": "Set whether to enable the MicrometerRoutePolicyFactory for capturing metrics on route processing times.", "sourceType": "org.apache.camel.main.MetricsConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": true },
+ { "name": "camel.opentelemetry.enabled", "description": "To enable OpenTelemetry", "sourceType": "org.apache.camel.main.OtelConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
{ "name": "camel.opentelemetry.encoding", "description": "Sets whether the header keys need to be encoded (connector specific) or not. The value is a boolean. Dashes need for instances to be encoded for JMS property keys.", "sourceType": "org.apache.camel.main.OtelConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
{ "name": "camel.opentelemetry.excludePatterns", "description": "Adds an exclude pattern that will disable tracing for Camel messages that matches the pattern. Multiple patterns can be separated by comma.", "sourceType": "org.apache.camel.main.OtelConfigurationProperties", "type": "string", "javaType": "java.lang.String" },
{ "name": "camel.opentelemetry.instrumentationName", "description": "A name uniquely identifying the instrumentation scope, such as the instrumentation library, package, or fully qualified class name. Must not be null.", "sourceType": "org.apache.camel.main.OtelConfigurationProperties", "type": "string", "javaType": "java.lang.String", "defaultValue": "camel" },
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/others.properties b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/others.properties
index 17cedb8b02b..ff8f24f02ba 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/others.properties
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/others.properties
@@ -27,6 +27,7 @@ lra
mail-microsoft-oauth
main
management
+micrometer-prometheus
microprofile-config
microprofile-fault-tolerance
microprofile-health
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/others/micrometer-prometheus.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/others/micrometer-prometheus.json
new file mode 100644
index 00000000000..de860450126
--- /dev/null
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/others/micrometer-prometheus.json
@@ -0,0 +1,14 @@
+{
+ "other": {
+ "kind": "other",
+ "name": "micrometer-prometheus",
+ "title": "Micrometer Prometheus",
+ "description": "Camel Micrometer Prometheus",
+ "deprecated": false,
+ "firstVersion": "4.3.0",
+ "supportLevel": "Preview",
+ "groupId": "org.apache.camel",
+ "artifactId": "camel-micrometer-prometheus",
+ "version": "4.3.0-SNAPSHOT"
+ }
+}
(camel) 03/16: CAMEL-20105: camel-micromemter - Make it easier to configure for camel-main
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch mm
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 5b61a3e506bacb1f7396ae1958497a81dfe7876e
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Nov 15 20:42:00 2023 +0100
CAMEL-20105: camel-micromemter - Make it easier to configure for camel-main
---
catalog/camel-allcomponents/pom.xml | 5 ++
components/camel-micrometer-prometheus/pom.xml | 99 ++++++++++++++++++++++
.../services/org/apache/camel/other.properties | 7 ++
.../generated/resources/micrometer-prometheus.json | 14 +++
.../src/test/resources/log4j2.properties | 2 +-
.../src/test/resources/log4j2.properties | 2 +-
components/pom.xml | 1 +
parent/pom.xml | 11 +++
8 files changed, 139 insertions(+), 2 deletions(-)
diff --git a/catalog/camel-allcomponents/pom.xml b/catalog/camel-allcomponents/pom.xml
index 8934ec40a3e..4f900d74593 100644
--- a/catalog/camel-allcomponents/pom.xml
+++ b/catalog/camel-allcomponents/pom.xml
@@ -1152,6 +1152,11 @@
<artifactId>camel-micrometer</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-micrometer-prometheus</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-microprofile-config</artifactId>
diff --git a/components/camel-micrometer-prometheus/pom.xml b/components/camel-micrometer-prometheus/pom.xml
new file mode 100644
index 00000000000..0bbb96068f9
--- /dev/null
+++ b/components/camel-micrometer-prometheus/pom.xml
@@ -0,0 +1,99 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>components</artifactId>
+ <version>4.3.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>camel-micrometer-prometheus</artifactId>
+ <packaging>jar</packaging>
+ <name>Camel :: Micrometer Prometheus</name>
+ <description>Camel Micrometer Prometheus</description>
+
+ <properties>
+ <firstVersion>4.3.0</firstVersion>
+ </properties>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-micrometer</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>io.micrometer</groupId>
+ <artifactId>micrometer-registry-prometheus</artifactId>
+ </dependency>
+
+ <!-- testing -->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-test-junit5</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-management</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-test-spring-junit5</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <artifactId>hamcrest-core</artifactId>
+ <groupId>org.hamcrest</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest</artifactId>
+ <version>${hamcrest-version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.assertj</groupId>
+ <artifactId>assertj-core</artifactId>
+ <version>${assertj-version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.awaitility</groupId>
+ <artifactId>awaitility</artifactId>
+ <version>${awaitility-version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/components/camel-micrometer-prometheus/src/generated/resources/META-INF/services/org/apache/camel/other.properties b/components/camel-micrometer-prometheus/src/generated/resources/META-INF/services/org/apache/camel/other.properties
new file mode 100644
index 00000000000..bb8c34ad8e2
--- /dev/null
+++ b/components/camel-micrometer-prometheus/src/generated/resources/META-INF/services/org/apache/camel/other.properties
@@ -0,0 +1,7 @@
+# Generated by camel build tools - do NOT edit this file!
+name=micrometer-prometheus
+groupId=org.apache.camel
+artifactId=camel-micrometer-prometheus
+version=4.3.0-SNAPSHOT
+projectName=Camel :: Micrometer Prometheus
+projectDescription=Camel Micrometer Prometheus
diff --git a/components/camel-micrometer-prometheus/src/generated/resources/micrometer-prometheus.json b/components/camel-micrometer-prometheus/src/generated/resources/micrometer-prometheus.json
new file mode 100644
index 00000000000..de860450126
--- /dev/null
+++ b/components/camel-micrometer-prometheus/src/generated/resources/micrometer-prometheus.json
@@ -0,0 +1,14 @@
+{
+ "other": {
+ "kind": "other",
+ "name": "micrometer-prometheus",
+ "title": "Micrometer Prometheus",
+ "description": "Camel Micrometer Prometheus",
+ "deprecated": false,
+ "firstVersion": "4.3.0",
+ "supportLevel": "Preview",
+ "groupId": "org.apache.camel",
+ "artifactId": "camel-micrometer-prometheus",
+ "version": "4.3.0-SNAPSHOT"
+ }
+}
diff --git a/components/camel-micrometer/src/test/resources/log4j2.properties b/components/camel-micrometer-prometheus/src/test/resources/log4j2.properties
similarity index 95%
copy from components/camel-micrometer/src/test/resources/log4j2.properties
copy to components/camel-micrometer-prometheus/src/test/resources/log4j2.properties
index 821d95af17d..f24ae625ca1 100644
--- a/components/camel-micrometer/src/test/resources/log4j2.properties
+++ b/components/camel-micrometer-prometheus/src/test/resources/log4j2.properties
@@ -17,7 +17,7 @@
appender.file.type = File
appender.file.name = file
-appender.file.fileName = target/camel-test-metrics.log
+appender.file.fileName = target/camel-test-micrometer-prometheus.log
appender.file.layout.type = PatternLayout
appender.file.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n
appender.out.type = Console
diff --git a/components/camel-micrometer/src/test/resources/log4j2.properties b/components/camel-micrometer/src/test/resources/log4j2.properties
index 821d95af17d..c66346429d7 100644
--- a/components/camel-micrometer/src/test/resources/log4j2.properties
+++ b/components/camel-micrometer/src/test/resources/log4j2.properties
@@ -17,7 +17,7 @@
appender.file.type = File
appender.file.name = file
-appender.file.fileName = target/camel-test-metrics.log
+appender.file.fileName = target/camel-test-micrometer.log
appender.file.layout.type = PatternLayout
appender.file.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n
appender.out.type = Console
diff --git a/components/pom.xml b/components/pom.xml
index 1998de8521e..4c6883bf99c 100644
--- a/components/pom.xml
+++ b/components/pom.xml
@@ -205,6 +205,7 @@
<module>camel-mapstruct</module>
<module>camel-metrics</module>
<module>camel-micrometer</module>
+ <module>camel-micrometer-prometheus</module>
<module>camel-microprofile</module>
<module>camel-mina</module>
<module>camel-minio</module>
diff --git a/parent/pom.xml b/parent/pom.xml
index 5f516cce023..64734e4ad97 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -1748,6 +1748,12 @@
<artifactId>camel-micrometer</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-micrometer-prometheus</artifactId>
+ <version>${project.version}</version>
+ <type>jar</type>
+ </dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-microprofile-config</artifactId>
@@ -2814,6 +2820,11 @@
<artifactId>micrometer-registry-jmx</artifactId>
<version>${micrometer-version}</version>
</dependency>
+ <dependency>
+ <groupId>io.micrometer</groupId>
+ <artifactId>micrometer-registry-prometheus</artifactId>
+ <version>${micrometer-version}</version>
+ </dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-tracing</artifactId>
(camel) 01/16: CAMEL-20105: camel-micromemter - Make it easier to configure for camel-main
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch mm
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 2b270a72a1ed254e6e38f1dfef524cdd07e66899
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Nov 15 20:23:11 2023 +0100
CAMEL-20105: camel-micromemter - Make it easier to configure for camel-main
---
.../MetricsConfigurationPropertiesConfigurer.java | 67 ++++++++++
.../camel-main-configuration-metadata.json | 5 +
...pache.camel.main.MetricsConfigurationProperties | 2 +
core/camel-main/src/main/docs/main.adoc | 13 ++
.../org/apache/camel/main/BaseMainSupport.java | 28 +++++
.../camel/main/MainConfigurationProperties.java | 22 ++++
.../camel/main/MetricsConfigurationProperties.java | 138 +++++++++++++++++++++
.../maven/packaging/PrepareCamelMainMojo.java | 5 +
8 files changed, 280 insertions(+)
diff --git a/core/camel-main/src/generated/java/org/apache/camel/main/MetricsConfigurationPropertiesConfigurer.java b/core/camel-main/src/generated/java/org/apache/camel/main/MetricsConfigurationPropertiesConfigurer.java
new file mode 100644
index 00000000000..e81062ff0eb
--- /dev/null
+++ b/core/camel-main/src/generated/java/org/apache/camel/main/MetricsConfigurationPropertiesConfigurer.java
@@ -0,0 +1,67 @@
+/* Generated by camel build tools - do NOT edit this file! */
+package org.apache.camel.main;
+
+import java.util.Map;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.spi.ExtendedPropertyConfigurerGetter;
+import org.apache.camel.spi.PropertyConfigurerGetter;
+import org.apache.camel.spi.ConfigurerStrategy;
+import org.apache.camel.spi.GeneratedPropertyConfigurer;
+import org.apache.camel.util.CaseInsensitiveMap;
+import org.apache.camel.main.MetricsConfigurationProperties;
+
+/**
+ * Generated by camel build tools - do NOT edit this file!
+ */
+@SuppressWarnings("unchecked")
+public class MetricsConfigurationPropertiesConfigurer extends org.apache.camel.support.component.PropertyConfigurerSupport implements GeneratedPropertyConfigurer, PropertyConfigurerGetter {
+
+ @Override
+ public boolean configure(CamelContext camelContext, Object obj, String name, Object value, boolean ignoreCase) {
+ org.apache.camel.main.MetricsConfigurationProperties target = (org.apache.camel.main.MetricsConfigurationProperties) obj;
+ switch (ignoreCase ? name.toLowerCase() : name) {
+ case "enableexchangeeventnotifier":
+ case "EnableExchangeEventNotifier": target.setEnableExchangeEventNotifier(property(camelContext, boolean.class, value)); return true;
+ case "enablemessagehistory":
+ case "EnableMessageHistory": target.setEnableMessageHistory(property(camelContext, boolean.class, value)); return true;
+ case "enablerouteeventnotifier":
+ case "EnableRouteEventNotifier": target.setEnableRouteEventNotifier(property(camelContext, boolean.class, value)); return true;
+ case "enableroutepolicy":
+ case "EnableRoutePolicy": target.setEnableRoutePolicy(property(camelContext, boolean.class, value)); return true;
+ default: return false;
+ }
+ }
+
+ @Override
+ public Class<?> getOptionType(String name, boolean ignoreCase) {
+ switch (ignoreCase ? name.toLowerCase() : name) {
+ case "enableexchangeeventnotifier":
+ case "EnableExchangeEventNotifier": return boolean.class;
+ case "enablemessagehistory":
+ case "EnableMessageHistory": return boolean.class;
+ case "enablerouteeventnotifier":
+ case "EnableRouteEventNotifier": return boolean.class;
+ case "enableroutepolicy":
+ case "EnableRoutePolicy": return boolean.class;
+ default: return null;
+ }
+ }
+
+ @Override
+ public Object getOptionValue(Object obj, String name, boolean ignoreCase) {
+ org.apache.camel.main.MetricsConfigurationProperties target = (org.apache.camel.main.MetricsConfigurationProperties) obj;
+ switch (ignoreCase ? name.toLowerCase() : name) {
+ case "enableexchangeeventnotifier":
+ case "EnableExchangeEventNotifier": return target.isEnableExchangeEventNotifier();
+ case "enablemessagehistory":
+ case "EnableMessageHistory": return target.isEnableMessageHistory();
+ case "enablerouteeventnotifier":
+ case "EnableRouteEventNotifier": return target.isEnableRouteEventNotifier();
+ case "enableroutepolicy":
+ case "EnableRoutePolicy": return target.isEnableRoutePolicy();
+ default: return null;
+ }
+ }
+}
+
diff --git a/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json b/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json
index 3a89ff173c1..d5a1d229594 100644
--- a/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json
+++ b/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json
@@ -11,6 +11,7 @@
{ "name": "camel.vault.gcp", "description": "Camel GCP Vault configurations", "sourceType": "org.apache.camel.vault.GcpVaultConfiguration" },
{ "name": "camel.vault.azure", "description": "Camel Azure Key Vault configurations", "sourceType": "org.apache.camel.vault.AzureVaultConfiguration" },
{ "name": "camel.opentelemetry", "description": "Camel OpenTelemtry configurations", "sourceType": "org.apache.camel.main.OtelConfigurationProperties" },
+ { "name": "camel.metrics", "description": "Camel Micrometer Metrics configurations", "sourceType": "org.apache.camel.main.MetricsConfigurationProperties" },
{ "name": "camel.faulttolerance", "description": "Fault Tolerance EIP Circuit Breaker configurations", "sourceType": "org.apache.camel.main.FaultToleranceConfigurationProperties" },
{ "name": "camel.resilience4j", "description": "Resilience4j EIP Circuit Breaker configurations", "sourceType": "org.apache.camel.main.Resilience4jConfigurationProperties" },
{ "name": "camel.lra", "description": "Camel Saga EIP (Long Running Actions) configurations", "sourceType": "org.apache.camel.main.LraConfigurationProperties" }
@@ -178,6 +179,10 @@
{ "name": "camel.lra.coordinatorUrl", "description": "The URL for the LRA coordinator service that orchestrates the transactions", "sourceType": "org.apache.camel.main.LraConfigurationProperties", "type": "string", "javaType": "java.lang.String" },
{ "name": "camel.lra.localParticipantContextPath", "description": "The context-path for the local participant. Is default \/lra-participant", "sourceType": "org.apache.camel.main.LraConfigurationProperties", "type": "string", "javaType": "java.lang.String", "defaultValue": "\/lra-participant" },
{ "name": "camel.lra.localParticipantUrl", "description": "The URL for the local participant", "sourceType": "org.apache.camel.main.LraConfigurationProperties", "type": "string", "javaType": "java.lang.String" },
+ { "name": "camel.metrics.enableExchangeEventNotifier", "description": "Set whether to enable the MicrometerExchangeEventNotifier for capturing metrics on exchange processing times.", "sourceType": "org.apache.camel.main.MetricsConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": true },
+ { "name": "camel.metrics.enableMessageHistory", "description": "Set whether to enable the MicrometerMessageHistoryFactory for capturing metrics on individual route node processing times. Depending on the number of configured route nodes, there is the potential to create a large volume of metrics. Therefore, this option is disabled by default.", "sourceType": "org.apache.camel.main.MetricsConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
+ { "name": "camel.metrics.enableRouteEventNotifier", "description": "Set whether to enable the MicrometerRouteEventNotifier for capturing metrics on the total number of routes and total number of routes running.", "sourceType": "org.apache.camel.main.MetricsConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": true },
+ { "name": "camel.metrics.enableRoutePolicy", "description": "Set whether to enable the MicrometerRoutePolicyFactory for capturing metrics on route processing times.", "sourceType": "org.apache.camel.main.MetricsConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": true },
{ "name": "camel.opentelemetry.encoding", "description": "Sets whether the header keys need to be encoded (connector specific) or not. The value is a boolean. Dashes need for instances to be encoded for JMS property keys.", "sourceType": "org.apache.camel.main.OtelConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
{ "name": "camel.opentelemetry.excludePatterns", "description": "Adds an exclude pattern that will disable tracing for Camel messages that matches the pattern. Multiple patterns can be separated by comma.", "sourceType": "org.apache.camel.main.OtelConfigurationProperties", "type": "string", "javaType": "java.lang.String" },
{ "name": "camel.opentelemetry.instrumentationName", "description": "A name uniquely identifying the instrumentation scope, such as the instrumentation library, package, or fully qualified class name. Must not be null.", "sourceType": "org.apache.camel.main.OtelConfigurationProperties", "type": "string", "javaType": "java.lang.String", "defaultValue": "camel" },
diff --git a/core/camel-main/src/generated/resources/META-INF/services/org/apache/camel/configurer/org.apache.camel.main.MetricsConfigurationProperties b/core/camel-main/src/generated/resources/META-INF/services/org/apache/camel/configurer/org.apache.camel.main.MetricsConfigurationProperties
new file mode 100644
index 00000000000..fd356d7ac12
--- /dev/null
+++ b/core/camel-main/src/generated/resources/META-INF/services/org/apache/camel/configurer/org.apache.camel.main.MetricsConfigurationProperties
@@ -0,0 +1,2 @@
+# Generated by camel build tools - do NOT edit this file!
+class=org.apache.camel.main.MetricsConfigurationPropertiesConfigurer
diff --git a/core/camel-main/src/main/docs/main.adoc b/core/camel-main/src/main/docs/main.adoc
index 3dee56918ae..c855cacb293 100644
--- a/core/camel-main/src/main/docs/main.adoc
+++ b/core/camel-main/src/main/docs/main.adoc
@@ -344,6 +344,19 @@ The camel.opentelemetry supports 3 options, which are listed below.
|===
+=== Camel Micrometer Metrics configurations
+The camel.metrics supports 4 options, which are listed below.
+
+[width="100%",cols="2,5,^1,2",options="header"]
+|===
+| Name | Description | Default | Type
+| *camel.metrics.enableExchange{zwsp}EventNotifier* | Set whether to enable the MicrometerExchangeEventNotifier for capturing metrics on exchange processing times. | true | boolean
+| *camel.metrics.enableMessage{zwsp}History* | Set whether to enable the MicrometerMessageHistoryFactory for capturing metrics on individual route node processing times. Depending on the number of configured route nodes, there is the potential to create a large volume of metrics. Therefore, this option is disabled by default. | false | boolean
+| *camel.metrics.enableRouteEvent{zwsp}Notifier* | Set whether to enable the MicrometerRouteEventNotifier for capturing metrics on the total number of routes and total number of routes running. | true | boolean
+| *camel.metrics.enableRoute{zwsp}Policy* | Set whether to enable the MicrometerRoutePolicyFactory for capturing metrics on route processing times. | true | boolean
+|===
+
+
=== Fault Tolerance EIP Circuit Breaker configurations
The camel.faulttolerance supports 13 options, which are listed below.
diff --git a/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java b/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java
index bbaff3f289e..fe09836d7f0 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java
@@ -952,6 +952,7 @@ public abstract class BaseMainSupport extends BaseService {
OrderedLocationProperties healthProperties = new OrderedLocationProperties();
OrderedLocationProperties lraProperties = new OrderedLocationProperties();
OrderedLocationProperties otelProperties = new OrderedLocationProperties();
+ OrderedLocationProperties metricsProperties = new OrderedLocationProperties();
OrderedLocationProperties routeTemplateProperties = new OrderedLocationProperties();
OrderedLocationProperties beansProperties = new OrderedLocationProperties();
OrderedLocationProperties devConsoleProperties = new OrderedLocationProperties();
@@ -1015,6 +1016,12 @@ public abstract class BaseMainSupport extends BaseService {
String option = key.substring(20);
validateOptionAndValue(key, option, value);
otelProperties.put(loc, optionKey(option), value);
+ } else if (key.startsWith("camel.metrics.")) {
+ // grab the value
+ String value = prop.getProperty(key);
+ String option = key.substring(14);
+ validateOptionAndValue(key, option, value);
+ metricsProperties.put(loc, optionKey(option), value);
} else if (key.startsWith("camel.routeTemplate")) {
// grab the value
String value = prop.getProperty(key);
@@ -1127,6 +1134,11 @@ public abstract class BaseMainSupport extends BaseService {
setOtelProperties(camelContext, otelProperties, mainConfigurationProperties.isAutoConfigurationFailFast(),
autoConfiguredProperties);
}
+ if (!metricsProperties.isEmpty() || mainConfigurationProperties.hasMetricsConfiguration()) {
+ LOG.debug("Auto-configuring Micrometer metrics from loaded properties: {}", metricsProperties.size());
+ setMetricsProperties(camelContext, metricsProperties, mainConfigurationProperties.isAutoConfigurationFailFast(),
+ autoConfiguredProperties);
+ }
if (!devConsoleProperties.isEmpty()) {
LOG.debug("Auto-configuring Dev Console from loaded properties: {}", devConsoleProperties.size());
setDevConsoleProperties(camelContext, devConsoleProperties,
@@ -1396,6 +1408,22 @@ public abstract class BaseMainSupport extends BaseService {
}
}
+ private void setMetricsProperties(
+ CamelContext camelContext, OrderedLocationProperties metricsProperties,
+ boolean failIfNotSet, OrderedLocationProperties autoConfiguredProperties)
+ throws Exception {
+
+ String loc = metricsProperties.getLocation("enabled");
+ Object obj = metricsProperties.remove("enabled");
+ if (ObjectHelper.isNotEmpty(obj)) {
+ autoConfiguredProperties.put(loc, "camel.metrics.enabled", obj.toString());
+ }
+ boolean enabled = obj != null ? CamelContextHelper.parseBoolean(camelContext, obj.toString()) : true;
+ if (enabled) {
+ // TODO:
+ }
+ }
+
private void setDevConsoleProperties(
CamelContext camelContext, OrderedLocationProperties properties,
boolean failIfNotSet, OrderedLocationProperties autoConfiguredProperties) {
diff --git a/core/camel-main/src/main/java/org/apache/camel/main/MainConfigurationProperties.java b/core/camel-main/src/main/java/org/apache/camel/main/MainConfigurationProperties.java
index 79273789d92..70300e16c70 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/MainConfigurationProperties.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/MainConfigurationProperties.java
@@ -54,6 +54,7 @@ public class MainConfigurationProperties extends DefaultConfigurationProperties<
private HealthConfigurationProperties healthConfigurationProperties;
private LraConfigurationProperties lraConfigurationProperties;
private OtelConfigurationProperties otelConfigurationProperties;
+ private MetricsConfigurationProperties metricsConfigurationProperties;
private ThreadPoolConfigurationProperties threadPoolProperties;
private Resilience4jConfigurationProperties resilience4jConfigurationProperties;
private FaultToleranceConfigurationProperties faultToleranceConfigurationProperties;
@@ -77,6 +78,10 @@ public class MainConfigurationProperties extends DefaultConfigurationProperties<
otelConfigurationProperties.close();
otelConfigurationProperties = null;
}
+ if (metricsConfigurationProperties != null) {
+ metricsConfigurationProperties.close();
+ metricsConfigurationProperties = null;
+ }
if (threadPoolProperties != null) {
threadPoolProperties.close();
threadPoolProperties = null;
@@ -173,6 +178,23 @@ public class MainConfigurationProperties extends DefaultConfigurationProperties<
return otelConfigurationProperties != null;
}
+ /**
+ * To configure Micrometer metrics.
+ */
+ public MetricsConfigurationProperties metrics() {
+ if (metricsConfigurationProperties == null) {
+ metricsConfigurationProperties = new MetricsConfigurationProperties(this);
+ }
+ return metricsConfigurationProperties;
+ }
+
+ /**
+ * Whether there has been any Micrometer metrics configuration specified
+ */
+ public boolean hasMetricsConfiguration() {
+ return metricsConfigurationProperties != null;
+ }
+
/**
* To configure embedded HTTP server (for standalone applications; not Spring Boot or Quarkus)
*/
diff --git a/core/camel-main/src/main/java/org/apache/camel/main/MetricsConfigurationProperties.java b/core/camel-main/src/main/java/org/apache/camel/main/MetricsConfigurationProperties.java
new file mode 100644
index 00000000000..ca54f8122c6
--- /dev/null
+++ b/core/camel-main/src/main/java/org/apache/camel/main/MetricsConfigurationProperties.java
@@ -0,0 +1,138 @@
+/*
+ * 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.main;
+
+import org.apache.camel.spi.BootstrapCloseable;
+import org.apache.camel.spi.Configurer;
+import org.apache.camel.spi.Metadata;
+
+/**
+ * Global configuration for Micrometer Metrics.
+ */
+@Configurer(bootstrap = true)
+public class MetricsConfigurationProperties implements BootstrapCloseable {
+
+ private MainConfigurationProperties parent;
+
+ @Metadata(defaultValue = "true")
+ private boolean enableRoutePolicy = true;
+ private boolean enableMessageHistory;
+ @Metadata(defaultValue = "true")
+ private boolean enableExchangeEventNotifier = true;
+ @Metadata(defaultValue = "true")
+ private boolean enableRouteEventNotifier = true;
+
+ public MetricsConfigurationProperties(MainConfigurationProperties parent) {
+ this.parent = parent;
+ }
+
+ public MainConfigurationProperties end() {
+ return parent;
+ }
+
+ public boolean isEnableRoutePolicy() {
+ return enableRoutePolicy;
+ }
+
+ /**
+ * Set whether to enable the MicrometerRoutePolicyFactory for capturing metrics on route processing times.
+ */
+ public void setEnableRoutePolicy(boolean enableRoutePolicy) {
+ this.enableRoutePolicy = enableRoutePolicy;
+ }
+
+ public boolean isEnableMessageHistory() {
+ return enableMessageHistory;
+ }
+
+ /**
+ * Set whether to enable the MicrometerMessageHistoryFactory for capturing metrics on individual route node
+ * processing times.
+ *
+ * Depending on the number of configured route nodes, there is the potential to create a large volume of metrics.
+ * Therefore, this option is disabled by default.
+ */
+ public void setEnableMessageHistory(boolean enableMessageHistory) {
+ this.enableMessageHistory = enableMessageHistory;
+ }
+
+ public boolean isEnableExchangeEventNotifier() {
+ return enableExchangeEventNotifier;
+ }
+
+ /**
+ * Set whether to enable the MicrometerExchangeEventNotifier for capturing metrics on exchange processing times.
+ */
+ public void setEnableExchangeEventNotifier(boolean enableExchangeEventNotifier) {
+ this.enableExchangeEventNotifier = enableExchangeEventNotifier;
+ }
+
+ public boolean isEnableRouteEventNotifier() {
+ return enableRouteEventNotifier;
+ }
+
+ /**
+ * Set whether to enable the MicrometerRouteEventNotifier for capturing metrics on the total number of routes and
+ * total number of routes running.
+ */
+ public void setEnableRouteEventNotifier(boolean enableRouteEventNotifier) {
+ this.enableRouteEventNotifier = enableRouteEventNotifier;
+ }
+
+ @Override
+ public void close() {
+ parent = null;
+ }
+
+ /**
+ * Set whether to enable the MicrometerRoutePolicyFactory for capturing metrics on route processing times.
+ */
+ public MetricsConfigurationProperties withEnableRoutePolicy(boolean enableRoutePolicy) {
+ this.enableRoutePolicy = enableRoutePolicy;
+ return this;
+ }
+
+ /**
+ * Set whether to enable the MicrometerMessageHistoryFactory for capturing metrics on individual route node
+ * processing times.
+ *
+ * Depending on the number of configured route nodes, there is the potential to create a large volume of metrics.
+ * Therefore, this option is disabled by default.
+ */
+ public MetricsConfigurationProperties withEnableMessageHistory(boolean enableMessageHistory) {
+ this.enableMessageHistory = enableMessageHistory;
+ return this;
+ }
+
+ /**
+ * Set whether to enable the MicrometerExchangeEventNotifier for capturing metrics on exchange processing times.
+ */
+ public MetricsConfigurationProperties withEnableExchangeEventNotifier(boolean enableExchangeEventNotifier) {
+ this.enableExchangeEventNotifier = enableExchangeEventNotifier;
+ return this;
+ }
+
+ /**
+ * Set whether to enable the MicrometerRouteEventNotifier for capturing metrics on the total number of routes and
+ * total number of routes running.
+ */
+ public MetricsConfigurationProperties witheEnableRouteEventNotifier(boolean enableRouteEventNotifier) {
+ this.enableRouteEventNotifier = enableRouteEventNotifier;
+ return this;
+ }
+
+}
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareCamelMainMojo.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareCamelMainMojo.java
index e5d80ece234..43789467da0 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareCamelMainMojo.java
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareCamelMainMojo.java
@@ -206,6 +206,8 @@ public class PrepareCamelMainMojo extends AbstractGeneratorMojo {
prefix = "camel.lra.";
} else if (file.getName().contains("Otel")) {
prefix = "camel.opentelemetry.";
+ } else if (file.getName().contains("Metrics")) {
+ prefix = "camel.metrics.";
} else if (file.getName().contains("HttpServer")) {
prefix = "camel.server.";
} else if (file.getName().contains("ThreadPoolProfileConfigurationProperties")) {
@@ -321,6 +323,9 @@ public class PrepareCamelMainMojo extends AbstractGeneratorMojo {
model.getGroups().add(new MainGroupModel(
"camel.opentelemetry", "Camel OpenTelemtry configurations",
"org.apache.camel.main.OtelConfigurationProperties"));
+ model.getGroups().add(new MainGroupModel(
+ "camel.metrics", "Camel Micrometer Metrics configurations",
+ "org.apache.camel.main.MetricsConfigurationProperties"));
model.getGroups()
.add(new MainGroupModel(
"camel.faulttolerance", "Fault Tolerance EIP Circuit Breaker configurations",
(camel) 11/16: CAMEL-20105: camel-micromemter - Make it easier to configure for camel-main
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch mm
in repository https://gitbox.apache.org/repos/asf/camel.git
commit a2e3befa30b9e5efe698104860be7dbdf75b381c
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Thu Nov 16 09:16:11 2023 +0100
CAMEL-20105: camel-micromemter - Make it easier to configure for camel-main
---
.../main/camel-main-configuration-metadata.json | 1 +
.../prometheus/MicrometerPrometheus.java | 22 ++++++++++------------
.../http/main/DefaultMainHttpServerFactory.java | 1 +
.../platform/http/main/MainHttpServer.java | 13 +++++++++++++
...ttpServerConfigurationPropertiesConfigurer.java | 6 ++++++
.../camel-main-configuration-metadata.json | 1 +
core/camel-main/src/main/docs/main.adoc | 3 ++-
.../main/HttpServerConfigurationProperties.java | 20 ++++++++++++++++++++
8 files changed, 54 insertions(+), 13 deletions(-)
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/camel-main-configuration-metadata.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/camel-main-configuration-metadata.json
index 5521078c575..92bef5801ed 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/camel-main-configuration-metadata.json
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/camel-main-configuration-metadata.json
@@ -242,6 +242,7 @@
{ "name": "camel.server.healthCheckEnabled", "description": "Whether to enable health-check console. If enabled then you can access health-check status on context-path: \/q\/health", "sourceType": "org.apache.camel.main.HttpServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
{ "name": "camel.server.host", "description": "Hostname to use for binding embedded HTTP server", "sourceType": "org.apache.camel.main.HttpServerConfigurationProperties", "type": "string", "javaType": "java.lang.String", "defaultValue": "0.0.0.0" },
{ "name": "camel.server.maxBodySize", "description": "Maximum HTTP body size the embedded HTTP server can accept.", "sourceType": "org.apache.camel.main.HttpServerConfigurationProperties", "type": "integer", "javaType": "java.lang.Long" },
+ { "name": "camel.server.metricsEnabled", "description": "Whether to enable metrics. If enabled then you can access metrics on context-path: \/q\/metrics", "sourceType": "org.apache.camel.main.HttpServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
{ "name": "camel.server.path", "description": "Context-path to use for embedded HTTP server", "sourceType": "org.apache.camel.main.HttpServerConfigurationProperties", "type": "string", "javaType": "java.lang.String", "defaultValue": "\/" },
{ "name": "camel.server.port", "description": "Port to use for binding embedded HTTP server", "sourceType": "org.apache.camel.main.HttpServerConfigurationProperties", "type": "integer", "javaType": "int", "defaultValue": 8080 },
{ "name": "camel.server.uploadEnabled", "description": "Whether to enable file upload via HTTP (not intended for production use). This functionality is for development to be able to reload Camel routes and code with source changes (if reload is enabled). If enabled then you can upload\/delete files via HTTP PUT\/DELETE on context-path: \/q\/upload\/{name}. You must also configure the uploadSourceDir option.", "sourceType": "org.apache.camel.main.HttpServerConfigurationProperties", "t [...]
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 37cd13762ce..61efbba632b 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
@@ -31,8 +31,8 @@ import org.apache.camel.component.micrometer.eventnotifier.MicrometerRouteEventN
import org.apache.camel.component.micrometer.messagehistory.MicrometerMessageHistoryFactory;
import org.apache.camel.component.micrometer.routepolicy.MicrometerRoutePolicyFactory;
import org.apache.camel.component.platform.http.PlatformHttpComponent;
+import org.apache.camel.component.platform.http.main.MainHttpServer;
import org.apache.camel.component.platform.http.vertx.VertxPlatformHttpRouter;
-import org.apache.camel.component.platform.http.vertx.VertxPlatformHttpServer;
import org.apache.camel.spi.CamelMetricsService;
import org.apache.camel.spi.Configurer;
import org.apache.camel.spi.ManagementStrategy;
@@ -49,16 +49,14 @@ public class MicrometerPrometheus extends ServiceSupport implements CamelMetrics
private static final Logger LOG = LoggerFactory.getLogger(MicrometerPrometheus.class);
- private VertxPlatformHttpServer server;
+ private MainHttpServer server;
private VertxPlatformHttpRouter router;
private PlatformHttpComponent platformHttpComponent;
- // TODO: option to configure prometheus (on or off)
// TODO: 0.0.4 or 1.0.0 text format
- // TODO: rename to camel-micrometer-main
+ // TODO: option include JVM metrics
+ // TODO: option include platform-http metrics
// TODO: include easily with jbang
- // TODO: camel.server.metricsEnabled=true|false
- // TODO: camel.server.otelEnabled=true|false
// TODO: docs
private CamelContext camelContext;
@@ -164,11 +162,11 @@ public class MicrometerPrometheus extends ServiceSupport implements CamelMetrics
camelContext.setMessageHistoryFactory(factory);
}
- server = camelContext.hasService(VertxPlatformHttpServer.class);
+ server = camelContext.hasService(MainHttpServer.class);
router = VertxPlatformHttpRouter.lookup(camelContext);
platformHttpComponent = camelContext.getComponent("platform-http", PlatformHttpComponent.class);
- if (server != null && router != null && platformHttpComponent != null) {
+ if (server != null && server.isMetricsEnabled() && router != null && platformHttpComponent != null) {
setupHttpScraper();
LOG.info("MicrometerPrometheus enabled with HTTP scraping on /q/metrics");
} else {
@@ -177,9 +175,9 @@ public class MicrometerPrometheus extends ServiceSupport implements CamelMetrics
}
protected void setupHttpScraper() {
- Route metrcis = router.route("/q/metrics");
- metrcis.method(HttpMethod.GET);
- metrcis.produces("text/plain;version=0.0.4;charset=utf-8");
+ Route metrics = router.route("/q/metrics");
+ metrics.method(HttpMethod.GET);
+ metrics.produces("text/plain;version=0.0.4;charset=utf-8");
Handler<RoutingContext> handler = new Handler<RoutingContext>() {
@Override
@@ -191,7 +189,7 @@ public class MicrometerPrometheus extends ServiceSupport implements CamelMetrics
};
// use blocking handler as the task can take longer time to complete
- metrcis.handler(new BlockingHandlerDecorator(handler, true));
+ metrics.handler(new BlockingHandlerDecorator(handler, true));
platformHttpComponent.addHttpEndpoint("/q/metrics", null, null);
}
diff --git a/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/DefaultMainHttpServerFactory.java b/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/DefaultMainHttpServerFactory.java
index f5bac97f9ec..967e536ba6b 100644
--- a/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/DefaultMainHttpServerFactory.java
+++ b/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/DefaultMainHttpServerFactory.java
@@ -53,6 +53,7 @@ public class DefaultMainHttpServerFactory implements CamelContextAware, MainHttp
server.setUseGlobalSslContextParameters(configuration.isUseGlobalSslContextParameters());
server.setDevConsoleEnabled(configuration.isDevConsoleEnabled());
server.setHealthCheckEnabled(configuration.isHealthCheckEnabled());
+ server.setMetricsEnabled(configuration.isMetricsEnabled());
server.setUploadEnabled(configuration.isUploadEnabled());
server.setUploadSourceDir(configuration.getUploadSourceDir());
diff --git a/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/MainHttpServer.java b/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/MainHttpServer.java
index e80cf310cc3..0738a279265 100644
--- a/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/MainHttpServer.java
+++ b/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/MainHttpServer.java
@@ -81,6 +81,7 @@ public class MainHttpServer extends ServiceSupport implements CamelContextAware,
private VertxPlatformHttpServerConfiguration configuration = new VertxPlatformHttpServerConfiguration();
private boolean devConsoleEnabled;
private boolean healthCheckEnabled;
+ private boolean metricsEnabled;
private boolean uploadEnabled;
private String uploadSourceDir;
@@ -124,6 +125,17 @@ public class MainHttpServer extends ServiceSupport implements CamelContextAware,
this.healthCheckEnabled = healthCheckEnabled;
}
+ public boolean isMetricsEnabled() {
+ return metricsEnabled;
+ }
+
+ /**
+ * Whether metrics is enabled (q/metrics)
+ */
+ public void setMetricsEnabled(boolean metricsEnabled) {
+ this.metricsEnabled = metricsEnabled;
+ }
+
public boolean isUploadEnabled() {
return uploadEnabled;
}
@@ -241,6 +253,7 @@ public class MainHttpServer extends ServiceSupport implements CamelContextAware,
}
setupUploadConsole(uploadSourceDir);
}
+ // metrics will be setup in camel-micrometer-prometheus
}
protected void setupStartupSummary() throws Exception {
diff --git a/core/camel-main/src/generated/java/org/apache/camel/main/HttpServerConfigurationPropertiesConfigurer.java b/core/camel-main/src/generated/java/org/apache/camel/main/HttpServerConfigurationPropertiesConfigurer.java
index 07c8e29295b..7479623930b 100644
--- a/core/camel-main/src/generated/java/org/apache/camel/main/HttpServerConfigurationPropertiesConfigurer.java
+++ b/core/camel-main/src/generated/java/org/apache/camel/main/HttpServerConfigurationPropertiesConfigurer.java
@@ -31,6 +31,8 @@ public class HttpServerConfigurationPropertiesConfigurer extends org.apache.came
case "Host": target.setHost(property(camelContext, java.lang.String.class, value)); return true;
case "maxbodysize":
case "MaxBodySize": target.setMaxBodySize(property(camelContext, java.lang.Long.class, value)); return true;
+ case "metricsenabled":
+ case "MetricsEnabled": target.setMetricsEnabled(property(camelContext, boolean.class, value)); return true;
case "path":
case "Path": target.setPath(property(camelContext, java.lang.String.class, value)); return true;
case "port":
@@ -58,6 +60,8 @@ public class HttpServerConfigurationPropertiesConfigurer extends org.apache.came
case "Host": return java.lang.String.class;
case "maxbodysize":
case "MaxBodySize": return java.lang.Long.class;
+ case "metricsenabled":
+ case "MetricsEnabled": return boolean.class;
case "path":
case "Path": return java.lang.String.class;
case "port":
@@ -86,6 +90,8 @@ public class HttpServerConfigurationPropertiesConfigurer extends org.apache.came
case "Host": return target.getHost();
case "maxbodysize":
case "MaxBodySize": return target.getMaxBodySize();
+ case "metricsenabled":
+ case "MetricsEnabled": return target.isMetricsEnabled();
case "path":
case "Path": return target.getPath();
case "port":
diff --git a/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json b/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json
index 5521078c575..92bef5801ed 100644
--- a/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json
+++ b/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json
@@ -242,6 +242,7 @@
{ "name": "camel.server.healthCheckEnabled", "description": "Whether to enable health-check console. If enabled then you can access health-check status on context-path: \/q\/health", "sourceType": "org.apache.camel.main.HttpServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
{ "name": "camel.server.host", "description": "Hostname to use for binding embedded HTTP server", "sourceType": "org.apache.camel.main.HttpServerConfigurationProperties", "type": "string", "javaType": "java.lang.String", "defaultValue": "0.0.0.0" },
{ "name": "camel.server.maxBodySize", "description": "Maximum HTTP body size the embedded HTTP server can accept.", "sourceType": "org.apache.camel.main.HttpServerConfigurationProperties", "type": "integer", "javaType": "java.lang.Long" },
+ { "name": "camel.server.metricsEnabled", "description": "Whether to enable metrics. If enabled then you can access metrics on context-path: \/q\/metrics", "sourceType": "org.apache.camel.main.HttpServerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
{ "name": "camel.server.path", "description": "Context-path to use for embedded HTTP server", "sourceType": "org.apache.camel.main.HttpServerConfigurationProperties", "type": "string", "javaType": "java.lang.String", "defaultValue": "\/" },
{ "name": "camel.server.port", "description": "Port to use for binding embedded HTTP server", "sourceType": "org.apache.camel.main.HttpServerConfigurationProperties", "type": "integer", "javaType": "int", "defaultValue": 8080 },
{ "name": "camel.server.uploadEnabled", "description": "Whether to enable file upload via HTTP (not intended for production use). This functionality is for development to be able to reload Camel routes and code with source changes (if reload is enabled). If enabled then you can upload\/delete files via HTTP PUT\/DELETE on context-path: \/q\/upload\/{name}. You must also configure the uploadSourceDir option.", "sourceType": "org.apache.camel.main.HttpServerConfigurationProperties", "t [...]
diff --git a/core/camel-main/src/main/docs/main.adoc b/core/camel-main/src/main/docs/main.adoc
index 9eb1ebfe7a9..22cbfb5a276 100644
--- a/core/camel-main/src/main/docs/main.adoc
+++ b/core/camel-main/src/main/docs/main.adoc
@@ -154,7 +154,7 @@ The camel.main supports 126 options, which are listed below.
=== Camel Embedded HTTP Server (only for standalone; not Spring Boot or Quarkus) configurations
-The camel.server supports 10 options, which are listed below.
+The camel.server supports 11 options, which are listed below.
[width="100%",cols="2,5,^1,2",options="header"]
|===
@@ -164,6 +164,7 @@ The camel.server supports 10 options, which are listed below.
| *camel.server.healthCheck{zwsp}Enabled* | Whether to enable health-check console. If enabled then you can access health-check status on context-path: /q/health | false | boolean
| *camel.server.host* | Hostname to use for binding embedded HTTP server | 0.0.0.0 | String
| *camel.server.maxBodySize* | Maximum HTTP body size the embedded HTTP server can accept. | | Long
+| *camel.server.metricsEnabled* | Whether to enable metrics. If enabled then you can access metrics on context-path: /q/metrics | false | boolean
| *camel.server.path* | Context-path to use for embedded HTTP server | / | String
| *camel.server.port* | Port to use for binding embedded HTTP server | 8080 | int
| *camel.server.uploadEnabled* | Whether to enable file upload via HTTP (not intended for production use). This functionality is for development to be able to reload Camel routes and code with source changes (if reload is enabled). If enabled then you can upload/delete files via HTTP PUT/DELETE on context-path: /q/upload/\{name}. You must also configure the uploadSourceDir option. | false | boolean
diff --git a/core/camel-main/src/main/java/org/apache/camel/main/HttpServerConfigurationProperties.java b/core/camel-main/src/main/java/org/apache/camel/main/HttpServerConfigurationProperties.java
index 2d9fb21e1ef..31ca9b144ec 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/HttpServerConfigurationProperties.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/HttpServerConfigurationProperties.java
@@ -41,6 +41,7 @@ public class HttpServerConfigurationProperties implements BootstrapCloseable {
private boolean devConsoleEnabled;
private boolean healthCheckEnabled;
+ private boolean metricsEnabled;
private boolean uploadEnabled;
private String uploadSourceDir;
@@ -149,6 +150,17 @@ public class HttpServerConfigurationProperties implements BootstrapCloseable {
this.healthCheckEnabled = healthCheckEnabled;
}
+ public boolean isMetricsEnabled() {
+ return metricsEnabled;
+ }
+
+ /**
+ * Whether to enable metrics. If enabled then you can access metrics on context-path: /q/metrics
+ */
+ public void setMetricsEnabled(boolean metricsEnabled) {
+ this.metricsEnabled = metricsEnabled;
+ }
+
public boolean isUploadEnabled() {
return uploadEnabled;
}
@@ -242,6 +254,14 @@ public class HttpServerConfigurationProperties implements BootstrapCloseable {
return this;
}
+ /**
+ * Whether to enable metrics. If enabled then you can access metrics on context-path: /q/metrics
+ */
+ public HttpServerConfigurationProperties withMetricsEnabled(boolean metricsEnabled) {
+ this.metricsEnabled = metricsEnabled;
+ return this;
+ }
+
/**
* Whether to enable file upload via HTTP (not intended for production use). This functionality is for development
* to be able to reload Camel routes and code with source changes (if reload is enabled). If enabled then you can
(camel) 07/16: CAMEL-20105: camel-micromemter - Make it easier to configure for camel-main
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch mm
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 4f585e2a4a73583eec163a81f266b01dac87ac1f
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Nov 15 21:29:28 2023 +0100
CAMEL-20105: camel-micromemter - Make it easier to configure for camel-main
---
components/camel-micrometer-prometheus/pom.xml | 6 ++-
.../services/org/apache/camel/other.properties | 2 +-
.../generated/resources/micrometer-prometheus.json | 2 +-
.../prometheus/MicrometerPrometheus.java | 48 ++++++++++++++++++++--
4 files changed, 51 insertions(+), 7 deletions(-)
diff --git a/components/camel-micrometer-prometheus/pom.xml b/components/camel-micrometer-prometheus/pom.xml
index 0bbb96068f9..72cb76f0fa3 100644
--- a/components/camel-micrometer-prometheus/pom.xml
+++ b/components/camel-micrometer-prometheus/pom.xml
@@ -29,7 +29,7 @@
<artifactId>camel-micrometer-prometheus</artifactId>
<packaging>jar</packaging>
<name>Camel :: Micrometer Prometheus</name>
- <description>Camel Micrometer Prometheus</description>
+ <description>Camel Micrometer Prometheus for Camel Main</description>
<properties>
<firstVersion>4.3.0</firstVersion>
@@ -41,6 +41,10 @@
<groupId>org.apache.camel</groupId>
<artifactId>camel-micrometer</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-platform-http-main</artifactId>
+ </dependency>
<dependency>
<groupId>io.micrometer</groupId>
diff --git a/components/camel-micrometer-prometheus/src/generated/resources/META-INF/services/org/apache/camel/other.properties b/components/camel-micrometer-prometheus/src/generated/resources/META-INF/services/org/apache/camel/other.properties
index bb8c34ad8e2..5c5e29db9e2 100644
--- a/components/camel-micrometer-prometheus/src/generated/resources/META-INF/services/org/apache/camel/other.properties
+++ b/components/camel-micrometer-prometheus/src/generated/resources/META-INF/services/org/apache/camel/other.properties
@@ -4,4 +4,4 @@ groupId=org.apache.camel
artifactId=camel-micrometer-prometheus
version=4.3.0-SNAPSHOT
projectName=Camel :: Micrometer Prometheus
-projectDescription=Camel Micrometer Prometheus
+projectDescription=Camel Micrometer Prometheus for Camel Main
diff --git a/components/camel-micrometer-prometheus/src/generated/resources/micrometer-prometheus.json b/components/camel-micrometer-prometheus/src/generated/resources/micrometer-prometheus.json
index de860450126..429ab2db753 100644
--- a/components/camel-micrometer-prometheus/src/generated/resources/micrometer-prometheus.json
+++ b/components/camel-micrometer-prometheus/src/generated/resources/micrometer-prometheus.json
@@ -3,7 +3,7 @@
"kind": "other",
"name": "micrometer-prometheus",
"title": "Micrometer Prometheus",
- "description": "Camel Micrometer Prometheus",
+ "description": "Camel Micrometer Prometheus for Camel Main",
"deprecated": false,
"firstVersion": "4.3.0",
"supportLevel": "Preview",
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 36946b45423..f909665a4d6 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
@@ -18,6 +18,11 @@ package org.apache.camel.component.micrometer.prometheus;
import io.micrometer.prometheus.PrometheusConfig;
import io.micrometer.prometheus.PrometheusMeterRegistry;
+import io.vertx.core.Handler;
+import io.vertx.core.http.HttpMethod;
+import io.vertx.ext.web.Route;
+import io.vertx.ext.web.RoutingContext;
+import io.vertx.ext.web.impl.BlockingHandlerDecorator;
import org.apache.camel.CamelContext;
import org.apache.camel.StaticService;
import org.apache.camel.api.management.ManagedResource;
@@ -25,6 +30,9 @@ import org.apache.camel.component.micrometer.eventnotifier.MicrometerExchangeEve
import org.apache.camel.component.micrometer.eventnotifier.MicrometerRouteEventNotifier;
import org.apache.camel.component.micrometer.messagehistory.MicrometerMessageHistoryFactory;
import org.apache.camel.component.micrometer.routepolicy.MicrometerRoutePolicyFactory;
+import org.apache.camel.component.platform.http.PlatformHttpComponent;
+import org.apache.camel.component.platform.http.vertx.VertxPlatformHttpRouter;
+import org.apache.camel.component.platform.http.vertx.VertxPlatformHttpServer;
import org.apache.camel.spi.CamelMetricsService;
import org.apache.camel.spi.Configurer;
import org.apache.camel.spi.ManagementStrategy;
@@ -41,9 +49,12 @@ public class MicrometerPrometheus extends ServiceSupport implements CamelMetrics
private static final Logger LOG = LoggerFactory.getLogger(MicrometerPrometheus.class);
- // TODO: option to configure prometheus
- // TODO: context-path / port for http scrape service
- // TODO: use platform-http-main
+ private VertxPlatformHttpServer server;
+ private VertxPlatformHttpRouter router;
+ private PlatformHttpComponent platformHttpComponent;
+
+ // TODO: option to configure prometheus (on or off)
+ // TODO: 0.0.4 or 1.0.0 text format
// TODO: dev console
private CamelContext camelContext;
@@ -149,6 +160,35 @@ public class MicrometerPrometheus extends ServiceSupport implements CamelMetrics
camelContext.setMessageHistoryFactory(factory);
}
- LOG.info("MicrometerPrometheus enabled");
+ server = camelContext.hasService(VertxPlatformHttpServer.class);
+ router = VertxPlatformHttpRouter.lookup(camelContext);
+ platformHttpComponent = camelContext.getComponent("platform-http", PlatformHttpComponent.class);
+
+ if (server != null && router != null && platformHttpComponent != null) {
+ setupHttpScraper();
+ LOG.info("MicrometerPrometheus enabled with HTTP scraping on /q/metrics");
+ } else {
+ LOG.info("MicrometerPrometheus enabled");
+ }
+ }
+
+ protected void setupHttpScraper() {
+ Route metrcis = router.route("/q/metrics");
+ metrcis.method(HttpMethod.GET);
+ metrcis.produces("text/plain;version=0.0.4;charset=utf-8");
+
+ Handler<RoutingContext> handler = new Handler<RoutingContext>() {
+ @Override
+ public void handle(RoutingContext ctx) {
+ ctx.response().putHeader("content-type", "text/plain;version=0.0.4;charset=utf-8");
+ String data = meterRegistry.scrape();
+ ctx.response().write(data);
+ }
+ };
+
+ // use blocking handler as the task can take longer time to complete
+ metrcis.handler(new BlockingHandlerDecorator(handler, true));
+
+ platformHttpComponent.addHttpEndpoint("/q/metrics", null, null);
}
}
(camel) 09/16: CAMEL-20105: camel-micromemter - Make it easier to configure for camel-main
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch mm
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 0daab91b3b9bcd9e2fe683ab26bc7954d681a7f5
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Thu Nov 16 06:23:59 2023 +0100
CAMEL-20105: camel-micromemter - Make it easier to configure for camel-main
---
.../camel/component/micrometer/prometheus/MicrometerPrometheus.java | 6 +++++-
1 file changed, 5 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 ad07eee99ae..37cd13762ce 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
@@ -55,7 +55,11 @@ public class MicrometerPrometheus extends ServiceSupport implements CamelMetrics
// TODO: option to configure prometheus (on or off)
// TODO: 0.0.4 or 1.0.0 text format
- // TODO: dev console
+ // TODO: rename to camel-micrometer-main
+ // TODO: include easily with jbang
+ // TODO: camel.server.metricsEnabled=true|false
+ // TODO: camel.server.otelEnabled=true|false
+ // TODO: docs
private CamelContext camelContext;
private final PrometheusMeterRegistry meterRegistry = new PrometheusMeterRegistry(PrometheusConfig.DEFAULT);
(camel) 14/16: CAMEL-20105: camel-micromemter - Make it easier to configure for camel-main
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch mm
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 222300e9087af3b833d539774c67c443bbef288d
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Thu Nov 16 15:05:13 2023 +0100
CAMEL-20105: camel-micromemter - Make it easier to configure for camel-main
---
components/camel-micrometer-prometheus/pom.xml | 44 +++++++++
.../micrometer/prometheus/JandexHelper.java | 44 +++++++++
.../prometheus/MicrometerPrometheusConfigurer.java | 6 ++
.../prometheus/MicrometerPrometheus.java | 102 ++++++++++++++++++++-
.../MetricsConfigurationPropertiesConfigurer.java | 6 ++
.../camel-main-configuration-metadata.json | 1 +
core/camel-main/src/main/docs/main.adoc | 3 +-
.../camel/main/MetricsConfigurationProperties.java | 22 +++++
8 files changed, 222 insertions(+), 6 deletions(-)
diff --git a/components/camel-micrometer-prometheus/pom.xml b/components/camel-micrometer-prometheus/pom.xml
index 72cb76f0fa3..d6e883369ec 100644
--- a/components/camel-micrometer-prometheus/pom.xml
+++ b/components/camel-micrometer-prometheus/pom.xml
@@ -46,10 +46,20 @@
<artifactId>camel-platform-http-main</artifactId>
</dependency>
+ <dependency>
+ <groupId>io.micrometer</groupId>
+ <artifactId>micrometer-core</artifactId>
+ </dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
</dependency>
+ <!-- to load micrometer binders -->
+ <dependency>
+ <groupId>io.smallrye</groupId>
+ <artifactId>jandex</artifactId>
+ <version>${jandex-version}</version>
+ </dependency>
<!-- testing -->
<dependency>
@@ -100,4 +110,38 @@
</dependencies>
+ <build>
+ <plugins>
+
+ <!-- generate jandex index for all the micrometer binders that can be enabled -->
+ <plugin>
+ <groupId>io.smallrye</groupId>
+ <artifactId>jandex-maven-plugin</artifactId>
+ <version>${jandex-version}</version>
+ <executions>
+ <execution>
+ <id>make-index</id>
+ <goals>
+ <goal>jandex</goal>
+ </goals>
+ <configuration>
+ <indexName>micrometer-binder-index.dat</indexName>
+ <fileSets>
+ <fileSet>
+ <dependency>
+ <groupId>io.micrometer</groupId>
+ <artifactId>micrometer-core</artifactId>
+ </dependency>
+ <includes>
+ <include>io/micrometer/core/instrument/binder/**/*.class</include>
+ </includes>
+ </fileSet>
+ </fileSets>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
</project>
diff --git a/components/camel-micrometer-prometheus/src/generated/java/org/apache/camel/component/micrometer/prometheus/JandexHelper.java b/components/camel-micrometer-prometheus/src/generated/java/org/apache/camel/component/micrometer/prometheus/JandexHelper.java
new file mode 100644
index 00000000000..93d05bbe4a4
--- /dev/null
+++ b/components/camel-micrometer-prometheus/src/generated/java/org/apache/camel/component/micrometer/prometheus/JandexHelper.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.micrometer.prometheus;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.util.IOHelper;
+import org.jboss.jandex.Index;
+import org.jboss.jandex.IndexReader;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+public final class JandexHelper {
+
+ private JandexHelper() {
+ }
+
+ public static Index readJandexIndex(CamelContext camelContext) throws IOException {
+ InputStream is = camelContext.getClassResolver().loadResourceAsStream("META-INF/micrometer-binder-index.dat");
+ try {
+ if (is != null) {
+ IndexReader reader = new IndexReader(is);
+ return reader.read();
+ }
+ } finally {
+ IOHelper.close(is);
+ }
+ return null;
+ }
+}
diff --git a/components/camel-micrometer-prometheus/src/generated/java/org/apache/camel/component/micrometer/prometheus/MicrometerPrometheusConfigurer.java b/components/camel-micrometer-prometheus/src/generated/java/org/apache/camel/component/micrometer/prometheus/MicrometerPrometheusConfigurer.java
index abad014040c..b18ea39de08 100644
--- a/components/camel-micrometer-prometheus/src/generated/java/org/apache/camel/component/micrometer/prometheus/MicrometerPrometheusConfigurer.java
+++ b/components/camel-micrometer-prometheus/src/generated/java/org/apache/camel/component/micrometer/prometheus/MicrometerPrometheusConfigurer.java
@@ -21,6 +21,8 @@ public class MicrometerPrometheusConfigurer extends org.apache.camel.support.com
public boolean configure(CamelContext camelContext, Object obj, String name, Object value, boolean ignoreCase) {
org.apache.camel.component.micrometer.prometheus.MicrometerPrometheus target = (org.apache.camel.component.micrometer.prometheus.MicrometerPrometheus) obj;
switch (ignoreCase ? name.toLowerCase() : name) {
+ case "binders":
+ case "Binders": target.setBinders(property(camelContext, java.lang.String.class, value)); return true;
case "camelcontext":
case "CamelContext": target.setCamelContext(property(camelContext, org.apache.camel.CamelContext.class, value)); return true;
case "enableexchangeeventnotifier":
@@ -40,6 +42,8 @@ public class MicrometerPrometheusConfigurer extends org.apache.camel.support.com
@Override
public Class<?> getOptionType(String name, boolean ignoreCase) {
switch (ignoreCase ? name.toLowerCase() : name) {
+ case "binders":
+ case "Binders": return java.lang.String.class;
case "camelcontext":
case "CamelContext": return org.apache.camel.CamelContext.class;
case "enableexchangeeventnotifier":
@@ -60,6 +64,8 @@ public class MicrometerPrometheusConfigurer extends org.apache.camel.support.com
public Object getOptionValue(Object obj, String name, boolean ignoreCase) {
org.apache.camel.component.micrometer.prometheus.MicrometerPrometheus target = (org.apache.camel.component.micrometer.prometheus.MicrometerPrometheus) obj;
switch (ignoreCase ? name.toLowerCase() : name) {
+ case "binders":
+ case "Binders": return target.getBinders();
case "camelcontext":
case "CamelContext": return target.getCamelContext();
case "enableexchangeeventnotifier":
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 1f20b3e3841..cb04572ad60 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
@@ -16,6 +16,15 @@
*/
package org.apache.camel.component.micrometer.prometheus;
+import java.io.Closeable;
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Optional;
+import java.util.Set;
+import java.util.StringJoiner;
+
+import io.micrometer.core.instrument.binder.MeterBinder;
import io.micrometer.prometheus.PrometheusConfig;
import io.micrometer.prometheus.PrometheusMeterRegistry;
import io.prometheus.client.exporter.common.TextFormat;
@@ -40,6 +49,11 @@ import org.apache.camel.spi.ManagementStrategy;
import org.apache.camel.spi.Metadata;
import org.apache.camel.spi.annotations.JdkService;
import org.apache.camel.support.service.ServiceSupport;
+import org.apache.camel.util.IOHelper;
+import org.apache.camel.util.StringHelper;
+import org.jboss.jandex.ClassInfo;
+import org.jboss.jandex.DotName;
+import org.jboss.jandex.Index;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -50,17 +64,18 @@ public class MicrometerPrometheus extends ServiceSupport implements CamelMetrics
private static final Logger LOG = LoggerFactory.getLogger(MicrometerPrometheus.class);
+ private static final String JANDEX_INDEX = "META-INF/micrometer-binder-index.dat";
+
private MainHttpServer server;
private VertxPlatformHttpRouter router;
private PlatformHttpComponent platformHttpComponent;
- // TODO: option include JVM metrics
- // TODO: option include platform-http metrics
// TODO: include easily with jbang
// TODO: docs
private CamelContext camelContext;
private final PrometheusMeterRegistry meterRegistry = new PrometheusMeterRegistry(PrometheusConfig.DEFAULT);
+ private final Set<MeterBinder> createdBinders = new HashSet<>();
@Metadata(defaultValue = "true")
private boolean enableRoutePolicy = true;
@@ -72,6 +87,8 @@ public class MicrometerPrometheus extends ServiceSupport implements CamelMetrics
private boolean enableRouteEventNotifier = true;
@Metadata(defaultValue = "0.0.4", enums = "0.0.4,1.0.0")
private String textFormatVersion = "0.0.4";
+ @Metadata
+ private String binders;
@Override
public CamelContext getCamelContext() {
@@ -139,17 +156,34 @@ public class MicrometerPrometheus extends ServiceSupport implements CamelMetrics
/**
* The text-format version to use with Prometheus scraping.
*
- * 0.0.4 = text/plain; version=0.0.4; charset=utf-8
- * 1.0.0 = application/openmetrics-text; version=1.0.0; charset=utf-8
+ * 0.0.4 = text/plain; version=0.0.4; charset=utf-8 1.0.0 = application/openmetrics-text; version=1.0.0;
+ * charset=utf-8
*/
public void setTextFormatVersion(String textFormatVersion) {
this.textFormatVersion = textFormatVersion;
}
+ public String getBinders() {
+ return binders;
+ }
+
+ /**
+ * Additional Micrometer binders to include such as jvm-memory, processor, jvm-thread, and so forth. Multiple
+ * binders can be separated by comma.
+ */
+ public void setBinders(String binders) {
+ this.binders = binders;
+ }
+
@Override
protected void doStart() throws Exception {
super.doStart();
+ if (binders != null) {
+ // load binders from micrometer
+ initBinders();
+ }
+
if (isEnableRoutePolicy()) {
MicrometerRoutePolicyFactory factory = new MicrometerRoutePolicyFactory();
factory.setMeterRegistry(meterRegistry);
@@ -190,11 +224,69 @@ public class MicrometerPrometheus extends ServiceSupport implements CamelMetrics
}
}
+ private void initBinders() throws IOException {
+ LOG.debug("Loading {}", JANDEX_INDEX);
+ Index index = JandexHelper.readJandexIndex(camelContext);
+ if (index == null) {
+ LOG.warn("Cannot read {} with list of known MeterBinder classes}", JANDEX_INDEX);
+ } else {
+ DotName dn = DotName.createSimple(MeterBinder.class);
+ List<ClassInfo> classes = index.getKnownDirectImplementors(dn);
+ LOG.debug("Found {} MeterBinder classes from {}", classes.size(), JANDEX_INDEX);
+
+ StringJoiner sj = new StringJoiner(", ");
+ for (String binder : binders.split(",")) {
+ binder = binder.trim();
+ binder = StringHelper.dashToCamelCase(binder);
+ binder = binder.toLowerCase();
+
+ final String target = binder;
+ Optional<ClassInfo> found = classes.stream()
+ // use naming convention with and without metrics
+ .filter(c -> c.name().local().toLowerCase().equals(target)
+ || c.name().local().toLowerCase().equals(target + "metrics"))
+ .findFirst();
+
+ if (found.isPresent()) {
+ String fqn = found.get().name().toString();
+ LOG.debug("Creating MeterBinder: {}", fqn);
+ try {
+ Class<MeterBinder> clazz = camelContext.getClassResolver().resolveClass(fqn, MeterBinder.class);
+ MeterBinder mb = camelContext.getInjector().newInstance(clazz);
+ if (mb != null) {
+ mb.bindTo(meterRegistry);
+ createdBinders.add(mb);
+ sj.add(mb.getClass().getSimpleName());
+ }
+ } catch (Exception e) {
+ LOG.warn("Error creating MeterBinder: {} due to: {}", fqn, e.getMessage(), e);
+ }
+ }
+ }
+ if (!createdBinders.isEmpty()) {
+ LOG.info("Registered {} MeterBinders: {}", createdBinders.size(), sj);
+ }
+ }
+ }
+
+ @Override
+ protected void doShutdown() throws Exception {
+ super.doShutdown();
+
+ for (MeterBinder mb : createdBinders) {
+ if (mb instanceof Closeable ac) {
+ IOHelper.close(ac);
+ }
+ }
+ createdBinders.clear();
+ }
+
protected void setupHttpScraper() {
Route metrics = router.route("/q/metrics");
metrics.method(HttpMethod.GET);
- final String format = "0.0.4".equals(textFormatVersion) ? TextFormat.CONTENT_TYPE_004 : TextFormat.CONTENT_TYPE_OPENMETRICS_100;
+ final String format
+ = "0.0.4".equals(textFormatVersion) ? TextFormat.CONTENT_TYPE_004 : TextFormat.CONTENT_TYPE_OPENMETRICS_100;
metrics.produces(format);
Handler<RoutingContext> handler = new Handler<RoutingContext>() {
diff --git a/core/camel-main/src/generated/java/org/apache/camel/main/MetricsConfigurationPropertiesConfigurer.java b/core/camel-main/src/generated/java/org/apache/camel/main/MetricsConfigurationPropertiesConfigurer.java
index ed323ad35fd..5ff6c35f698 100644
--- a/core/camel-main/src/generated/java/org/apache/camel/main/MetricsConfigurationPropertiesConfigurer.java
+++ b/core/camel-main/src/generated/java/org/apache/camel/main/MetricsConfigurationPropertiesConfigurer.java
@@ -21,6 +21,8 @@ public class MetricsConfigurationPropertiesConfigurer extends org.apache.camel.s
public boolean configure(CamelContext camelContext, Object obj, String name, Object value, boolean ignoreCase) {
org.apache.camel.main.MetricsConfigurationProperties target = (org.apache.camel.main.MetricsConfigurationProperties) obj;
switch (ignoreCase ? name.toLowerCase() : name) {
+ case "binders":
+ case "Binders": target.setBinders(property(camelContext, java.lang.String.class, value)); return true;
case "enableexchangeeventnotifier":
case "EnableExchangeEventNotifier": target.setEnableExchangeEventNotifier(property(camelContext, boolean.class, value)); return true;
case "enablemessagehistory":
@@ -40,6 +42,8 @@ public class MetricsConfigurationPropertiesConfigurer extends org.apache.camel.s
@Override
public Class<?> getOptionType(String name, boolean ignoreCase) {
switch (ignoreCase ? name.toLowerCase() : name) {
+ case "binders":
+ case "Binders": return java.lang.String.class;
case "enableexchangeeventnotifier":
case "EnableExchangeEventNotifier": return boolean.class;
case "enablemessagehistory":
@@ -60,6 +64,8 @@ public class MetricsConfigurationPropertiesConfigurer extends org.apache.camel.s
public Object getOptionValue(Object obj, String name, boolean ignoreCase) {
org.apache.camel.main.MetricsConfigurationProperties target = (org.apache.camel.main.MetricsConfigurationProperties) obj;
switch (ignoreCase ? name.toLowerCase() : name) {
+ case "binders":
+ case "Binders": return target.getBinders();
case "enableexchangeeventnotifier":
case "EnableExchangeEventNotifier": return target.isEnableExchangeEventNotifier();
case "enablemessagehistory":
diff --git a/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json b/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json
index 22167f65ed6..b394013bf78 100644
--- a/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json
+++ b/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json
@@ -180,6 +180,7 @@
{ "name": "camel.lra.enabled", "description": "To enable Saga LRA", "sourceType": "org.apache.camel.main.LraConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": false },
{ "name": "camel.lra.localParticipantContextPath", "description": "The context-path for the local participant. Is default \/lra-participant", "sourceType": "org.apache.camel.main.LraConfigurationProperties", "type": "string", "javaType": "java.lang.String", "defaultValue": "\/lra-participant" },
{ "name": "camel.lra.localParticipantUrl", "description": "The URL for the local participant", "sourceType": "org.apache.camel.main.LraConfigurationProperties", "type": "string", "javaType": "java.lang.String" },
+ { "name": "camel.metrics.binders", "description": "Additional Micrometer binders to include such as jvm-memory, processor, jvm-thread, and so forth. Multiple binders can be separated by comma.", "sourceType": "org.apache.camel.main.MetricsConfigurationProperties", "type": "string", "javaType": "java.lang.String" },
{ "name": "camel.metrics.enabled", "description": "To enable Micrometer metrics.", "sourceType": "org.apache.camel.main.MetricsConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
{ "name": "camel.metrics.enableExchangeEventNotifier", "description": "Set whether to enable the MicrometerExchangeEventNotifier for capturing metrics on exchange processing times.", "sourceType": "org.apache.camel.main.MetricsConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": true },
{ "name": "camel.metrics.enableMessageHistory", "description": "Set whether to enable the MicrometerMessageHistoryFactory for capturing metrics on individual route node processing times. Depending on the number of configured route nodes, there is the potential to create a large volume of metrics. Therefore, this option is disabled by default.", "sourceType": "org.apache.camel.main.MetricsConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" },
diff --git a/core/camel-main/src/main/docs/main.adoc b/core/camel-main/src/main/docs/main.adoc
index 426dff178b1..14021ec8ebf 100644
--- a/core/camel-main/src/main/docs/main.adoc
+++ b/core/camel-main/src/main/docs/main.adoc
@@ -347,11 +347,12 @@ The camel.opentelemetry supports 4 options, which are listed below.
=== Camel Micrometer Metrics configurations
-The camel.metrics supports 6 options, which are listed below.
+The camel.metrics supports 7 options, which are listed below.
[width="100%",cols="2,5,^1,2",options="header"]
|===
| Name | Description | Default | Type
+| *camel.metrics.binders* | Additional Micrometer binders to include such as jvm-memory, processor, jvm-thread, and so forth. Multiple binders can be separated by comma. | | String
| *camel.metrics.enabled* | To enable Micrometer metrics. | false | boolean
| *camel.metrics.enableExchange{zwsp}EventNotifier* | Set whether to enable the MicrometerExchangeEventNotifier for capturing metrics on exchange processing times. | true | boolean
| *camel.metrics.enableMessage{zwsp}History* | Set whether to enable the MicrometerMessageHistoryFactory for capturing metrics on individual route node processing times. Depending on the number of configured route nodes, there is the potential to create a large volume of metrics. Therefore, this option is disabled by default. | false | boolean
diff --git a/core/camel-main/src/main/java/org/apache/camel/main/MetricsConfigurationProperties.java b/core/camel-main/src/main/java/org/apache/camel/main/MetricsConfigurationProperties.java
index dd55c2951c3..badc1b27506 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/MetricsConfigurationProperties.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/MetricsConfigurationProperties.java
@@ -38,6 +38,8 @@ public class MetricsConfigurationProperties implements BootstrapCloseable {
private boolean enableRouteEventNotifier = true;
@Metadata(defaultValue = "0.0.4", enums = "0.0.4,1.0.0")
private String textFormatVersion = "0.0.4";
+ @Metadata
+ private String binders;
public MetricsConfigurationProperties(MainConfigurationProperties parent) {
this.parent = parent;
@@ -121,6 +123,18 @@ public class MetricsConfigurationProperties implements BootstrapCloseable {
this.textFormatVersion = textFormatVersion;
}
+ public String getBinders() {
+ return binders;
+ }
+
+ /**
+ * Additional Micrometer binders to include such as jvm-memory, processor, jvm-thread, and so forth. Multiple
+ * binders can be separated by comma.
+ */
+ public void setBinders(String binders) {
+ this.binders = binders;
+ }
+
@Override
public void close() {
parent = null;
@@ -182,5 +196,13 @@ public class MetricsConfigurationProperties implements BootstrapCloseable {
return this;
}
+ /**
+ * Additional Micrometer binders to include such as jvm-memory, processor, jvm-thread, and so forth. Multiple
+ * binders can be separated by comma.
+ */
+ public MetricsConfigurationProperties withbinders(String binders) {
+ this.binders = binders;
+ return this;
+ }
}
(camel) 04/16: CAMEL-20105: camel-micromemter - Make it easier to configure for camel-main
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch mm
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 17cb3fd9c112b4abc6a161e3d2db9d5494f74cb7
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Nov 15 21:01:05 2023 +0100
CAMEL-20105: camel-micromemter - Make it easier to configure for camel-main
---
.../prometheus/MicrometerPrometheusConfigurer.java | 73 ++++++++++
...nent.micrometer.prometheus.MicrometerPrometheus | 2 +
.../org/apache/camel/micrometer-prometheus | 2 +
.../prometheus/MicrometerPrometheus.java | 152 +++++++++++++++++++++
.../org/apache/camel/spi/CamelMetricsService.java | 27 ++++
.../org/apache/camel/main/BaseMainSupport.java | 23 +++-
parent/pom.xml | 1 -
7 files changed, 278 insertions(+), 2 deletions(-)
diff --git a/components/camel-micrometer-prometheus/src/generated/java/org/apache/camel/component/micrometer/prometheus/MicrometerPrometheusConfigurer.java b/components/camel-micrometer-prometheus/src/generated/java/org/apache/camel/component/micrometer/prometheus/MicrometerPrometheusConfigurer.java
new file mode 100644
index 00000000000..2f934e1d64e
--- /dev/null
+++ b/components/camel-micrometer-prometheus/src/generated/java/org/apache/camel/component/micrometer/prometheus/MicrometerPrometheusConfigurer.java
@@ -0,0 +1,73 @@
+/* Generated by camel build tools - do NOT edit this file! */
+package org.apache.camel.component.micrometer.prometheus;
+
+import java.util.Map;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.spi.ExtendedPropertyConfigurerGetter;
+import org.apache.camel.spi.PropertyConfigurerGetter;
+import org.apache.camel.spi.ConfigurerStrategy;
+import org.apache.camel.spi.GeneratedPropertyConfigurer;
+import org.apache.camel.util.CaseInsensitiveMap;
+import org.apache.camel.component.micrometer.prometheus.MicrometerPrometheus;
+
+/**
+ * Generated by camel build tools - do NOT edit this file!
+ */
+@SuppressWarnings("unchecked")
+public class MicrometerPrometheusConfigurer extends org.apache.camel.support.component.PropertyConfigurerSupport implements GeneratedPropertyConfigurer, PropertyConfigurerGetter {
+
+ @Override
+ public boolean configure(CamelContext camelContext, Object obj, String name, Object value, boolean ignoreCase) {
+ org.apache.camel.component.micrometer.prometheus.MicrometerPrometheus target = (org.apache.camel.component.micrometer.prometheus.MicrometerPrometheus) obj;
+ switch (ignoreCase ? name.toLowerCase() : name) {
+ case "camelcontext":
+ case "CamelContext": target.setCamelContext(property(camelContext, org.apache.camel.CamelContext.class, value)); return true;
+ case "enableexchangeeventnotifier":
+ case "EnableExchangeEventNotifier": target.setEnableExchangeEventNotifier(property(camelContext, boolean.class, value)); return true;
+ case "enablemessagehistory":
+ case "EnableMessageHistory": target.setEnableMessageHistory(property(camelContext, boolean.class, value)); return true;
+ case "enablerouteeventnotifier":
+ case "EnableRouteEventNotifier": target.setEnableRouteEventNotifier(property(camelContext, boolean.class, value)); return true;
+ case "enableroutepolicy":
+ case "EnableRoutePolicy": target.setEnableRoutePolicy(property(camelContext, boolean.class, value)); return true;
+ default: return false;
+ }
+ }
+
+ @Override
+ public Class<?> getOptionType(String name, boolean ignoreCase) {
+ switch (ignoreCase ? name.toLowerCase() : name) {
+ case "camelcontext":
+ case "CamelContext": return org.apache.camel.CamelContext.class;
+ case "enableexchangeeventnotifier":
+ case "EnableExchangeEventNotifier": return boolean.class;
+ case "enablemessagehistory":
+ case "EnableMessageHistory": return boolean.class;
+ case "enablerouteeventnotifier":
+ case "EnableRouteEventNotifier": return boolean.class;
+ case "enableroutepolicy":
+ case "EnableRoutePolicy": return boolean.class;
+ default: return null;
+ }
+ }
+
+ @Override
+ public Object getOptionValue(Object obj, String name, boolean ignoreCase) {
+ org.apache.camel.component.micrometer.prometheus.MicrometerPrometheus target = (org.apache.camel.component.micrometer.prometheus.MicrometerPrometheus) obj;
+ switch (ignoreCase ? name.toLowerCase() : name) {
+ case "camelcontext":
+ case "CamelContext": return target.getCamelContext();
+ case "enableexchangeeventnotifier":
+ case "EnableExchangeEventNotifier": return target.isEnableExchangeEventNotifier();
+ case "enablemessagehistory":
+ case "EnableMessageHistory": return target.isEnableMessageHistory();
+ case "enablerouteeventnotifier":
+ case "EnableRouteEventNotifier": return target.isEnableRouteEventNotifier();
+ case "enableroutepolicy":
+ case "EnableRoutePolicy": return target.isEnableRoutePolicy();
+ default: return null;
+ }
+ }
+}
+
diff --git a/components/camel-micrometer-prometheus/src/generated/resources/META-INF/services/org/apache/camel/configurer/org.apache.camel.component.micrometer.prometheus.MicrometerPrometheus b/components/camel-micrometer-prometheus/src/generated/resources/META-INF/services/org/apache/camel/configurer/org.apache.camel.component.micrometer.prometheus.MicrometerPrometheus
new file mode 100644
index 00000000000..9f7e2f12222
--- /dev/null
+++ b/components/camel-micrometer-prometheus/src/generated/resources/META-INF/services/org/apache/camel/configurer/org.apache.camel.component.micrometer.prometheus.MicrometerPrometheus
@@ -0,0 +1,2 @@
+# Generated by camel build tools - do NOT edit this file!
+class=org.apache.camel.component.micrometer.prometheus.MicrometerPrometheusConfigurer
diff --git a/components/camel-micrometer-prometheus/src/generated/resources/META-INF/services/org/apache/camel/micrometer-prometheus b/components/camel-micrometer-prometheus/src/generated/resources/META-INF/services/org/apache/camel/micrometer-prometheus
new file mode 100644
index 00000000000..aef3c09ef27
--- /dev/null
+++ b/components/camel-micrometer-prometheus/src/generated/resources/META-INF/services/org/apache/camel/micrometer-prometheus
@@ -0,0 +1,2 @@
+# Generated by camel build tools - do NOT edit this file!
+class=org.apache.camel.component.micrometer.prometheus.MicrometerPrometheus
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
new file mode 100644
index 00000000000..b6fee55cb02
--- /dev/null
+++ b/components/camel-micrometer-prometheus/src/main/java/org/apache/camel/component/micrometer/prometheus/MicrometerPrometheus.java
@@ -0,0 +1,152 @@
+/*
+ * 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.micrometer.prometheus;
+
+import io.micrometer.prometheus.PrometheusConfig;
+import io.micrometer.prometheus.PrometheusMeterRegistry;
+import org.apache.camel.CamelContext;
+import org.apache.camel.StaticService;
+import org.apache.camel.api.management.ManagedResource;
+import org.apache.camel.component.micrometer.eventnotifier.MicrometerExchangeEventNotifier;
+import org.apache.camel.component.micrometer.eventnotifier.MicrometerRouteEventNotifier;
+import org.apache.camel.component.micrometer.messagehistory.MicrometerMessageHistoryFactory;
+import org.apache.camel.component.micrometer.routepolicy.MicrometerRoutePolicyFactory;
+import org.apache.camel.spi.CamelMetricsService;
+import org.apache.camel.spi.Configurer;
+import org.apache.camel.spi.ManagementStrategy;
+import org.apache.camel.spi.Metadata;
+import org.apache.camel.spi.annotations.JdkService;
+import org.apache.camel.support.service.ServiceSupport;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@JdkService("micrometer-prometheus")
+@Configurer
+@ManagedResource(description = "Micrometer Metrics Prometheus")
+public class MicrometerPrometheus extends ServiceSupport implements CamelMetricsService, StaticService {
+
+ private static final Logger LOG = LoggerFactory.getLogger(MicrometerPrometheus.class);
+
+ // TODO: option to configure prometheus
+ // TODO: context-path / port for http scrape service
+
+ private CamelContext camelContext;
+ private final PrometheusMeterRegistry meterRegistry = new PrometheusMeterRegistry(PrometheusConfig.DEFAULT);
+
+ @Metadata(defaultValue = "true")
+ private boolean enableRoutePolicy = true;
+ @Metadata(defaultValue = "false")
+ private boolean enableMessageHistory;
+ @Metadata(defaultValue = "true")
+ private boolean enableExchangeEventNotifier = true;
+ @Metadata(defaultValue = "true")
+ private boolean enableRouteEventNotifier = true;
+
+ @Override
+ public CamelContext getCamelContext() {
+ return camelContext;
+ }
+
+ @Override
+ public void setCamelContext(CamelContext camelContext) {
+ this.camelContext = camelContext;
+ }
+
+ public boolean isEnableRoutePolicy() {
+ return enableRoutePolicy;
+ }
+
+ /**
+ * Set whether to enable the MicrometerRoutePolicyFactory for capturing metrics on route processing times.
+ */
+ public void setEnableRoutePolicy(boolean enableRoutePolicy) {
+ this.enableRoutePolicy = enableRoutePolicy;
+ }
+
+ public boolean isEnableMessageHistory() {
+ return enableMessageHistory;
+ }
+
+ /**
+ * Set whether to enable the MicrometerMessageHistoryFactory for capturing metrics on individual route node
+ * processing times.
+ *
+ * Depending on the number of configured route nodes, there is the potential to create a large volume of metrics.
+ * Therefore, this option is disabled by default.
+ */
+ public void setEnableMessageHistory(boolean enableMessageHistory) {
+ this.enableMessageHistory = enableMessageHistory;
+ }
+
+ public boolean isEnableExchangeEventNotifier() {
+ return enableExchangeEventNotifier;
+ }
+
+ /**
+ * Set whether to enable the MicrometerExchangeEventNotifier for capturing metrics on exchange processing times.
+ */
+ public void setEnableExchangeEventNotifier(boolean enableExchangeEventNotifier) {
+ this.enableExchangeEventNotifier = enableExchangeEventNotifier;
+ }
+
+ public boolean isEnableRouteEventNotifier() {
+ return enableRouteEventNotifier;
+ }
+
+ /**
+ * Set whether to enable the MicrometerRouteEventNotifier for capturing metrics on the total number of routes and
+ * total number of routes running.
+ */
+ public void setEnableRouteEventNotifier(boolean enableRouteEventNotifier) {
+ this.enableRouteEventNotifier = enableRouteEventNotifier;
+ }
+
+ @Override
+ protected void doStart() throws Exception {
+ super.doStart();
+
+ if (isEnableRoutePolicy()) {
+ MicrometerRoutePolicyFactory factory = new MicrometerRoutePolicyFactory();
+ factory.setMeterRegistry(meterRegistry);
+ camelContext.addRoutePolicyFactory(factory);
+ }
+
+ ManagementStrategy managementStrategy = camelContext.getManagementStrategy();
+ if (isEnableExchangeEventNotifier()) {
+ MicrometerExchangeEventNotifier notifier = new MicrometerExchangeEventNotifier();
+ notifier.setMeterRegistry(meterRegistry);
+ managementStrategy.addEventNotifier(notifier);
+ }
+
+ if (isEnableRouteEventNotifier()) {
+ MicrometerRouteEventNotifier notifier = new MicrometerRouteEventNotifier();
+ notifier.setMeterRegistry(meterRegistry);
+ managementStrategy.addEventNotifier(notifier);
+ }
+
+ if (isEnableMessageHistory()) {
+ if (!camelContext.isMessageHistory()) {
+ camelContext.setMessageHistory(true);
+ }
+ MicrometerMessageHistoryFactory factory = new MicrometerMessageHistoryFactory();
+ factory.setMeterRegistry(meterRegistry);
+ camelContext.setMessageHistoryFactory(factory);
+ }
+
+ LOG.info("MicrometerPrometheus enabled");
+ }
+}
diff --git a/core/camel-api/src/generated/java/org/apache/camel/spi/CamelMetricsService.java b/core/camel-api/src/generated/java/org/apache/camel/spi/CamelMetricsService.java
new file mode 100644
index 00000000000..9dcf87829c5
--- /dev/null
+++ b/core/camel-api/src/generated/java/org/apache/camel/spi/CamelMetricsService.java
@@ -0,0 +1,27 @@
+/*
+ * 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.spi;
+
+import org.apache.camel.CamelContextAware;
+import org.apache.camel.Service;
+
+/**
+ * A Camel metrics service is a factory for micrometer metrics.
+ */
+public interface CamelMetricsService extends Service, CamelContextAware {
+
+}
diff --git a/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java b/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java
index fe09836d7f0..660fa08e5f6 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java
@@ -57,6 +57,7 @@ import org.apache.camel.spi.AutowiredLifecycleStrategy;
import org.apache.camel.spi.BacklogDebugger;
import org.apache.camel.spi.CamelBeanPostProcessor;
import org.apache.camel.spi.CamelEvent;
+import org.apache.camel.spi.CamelMetricsService;
import org.apache.camel.spi.CamelTracingService;
import org.apache.camel.spi.ContextReloadStrategy;
import org.apache.camel.spi.DataFormat;
@@ -1420,7 +1421,13 @@ public abstract class BaseMainSupport extends BaseService {
}
boolean enabled = obj != null ? CamelContextHelper.parseBoolean(camelContext, obj.toString()) : true;
if (enabled) {
- // TODO:
+ CamelMetricsService micrometer = resolveMicrometerService(camelContext);
+ setPropertiesOnTarget(camelContext, micrometer, metricsProperties, "camel.metrics.", failIfNotSet, true,
+ autoConfiguredProperties);
+ if (camelContext.hasService(CamelMetricsService.class) == null) {
+ // add as service so micrometer can be active
+ camelContext.addService(micrometer, true, true);
+ }
}
}
@@ -2079,6 +2086,20 @@ public abstract class BaseMainSupport extends BaseService {
return answer;
}
+ private static CamelMetricsService resolveMicrometerService(CamelContext camelContext) throws Exception {
+ CamelMetricsService answer = camelContext.hasService(CamelMetricsService.class);
+ if (answer == null) {
+ answer = camelContext.getRegistry().findSingleByType(CamelMetricsService.class);
+ }
+ if (answer == null) {
+ answer = camelContext.getCamelContextExtension().getBootstrapFactoryFinder()
+ .newInstance("micrometer-prometheus", CamelMetricsService.class)
+ .orElseThrow(() -> new IllegalArgumentException(
+ "Cannot find CamelMetricsService on classpath. Add camel-micrometer-prometheus to classpath."));
+ }
+ return answer;
+ }
+
private static MainHttpServerFactory resolveMainHttpServerFactory(CamelContext camelContext) {
// lookup in service registry first
MainHttpServerFactory answer = camelContext.getRegistry().findSingleByType(MainHttpServerFactory.class);
diff --git a/parent/pom.xml b/parent/pom.xml
index 64734e4ad97..a5f985fc7ed 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -1752,7 +1752,6 @@
<groupId>org.apache.camel</groupId>
<artifactId>camel-micrometer-prometheus</artifactId>
<version>${project.version}</version>
- <type>jar</type>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
(camel) 13/16: Upgrade to jandex 3.1.5
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch mm
in repository https://gitbox.apache.org/repos/asf/camel.git
commit ba22ceeff9a1638206d68b54a347e958886c0a55
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Thu Nov 16 14:14:42 2023 +0100
Upgrade to jandex 3.1.5
---
parent/pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/parent/pom.xml b/parent/pom.xml
index a5f985fc7ed..ebe9ddf0fc1 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -222,7 +222,7 @@
<jackson2-version>2.15.2</jackson2-version>
<jackrabbit-version>2.21.20</jackrabbit-version>
<jasminb-jsonapi-version>0.13</jasminb-jsonapi-version>
- <jandex-version>3.1.2</jandex-version>
+ <jandex-version>3.1.5</jandex-version>
<jansi-version>2.4.0</jansi-version>
<jasypt-version>1.9.3</jasypt-version>
<java-grok-version>0.1.9</java-grok-version>
(camel) 06/16: CAMEL-20105: camel-micromemter - Make it easier to configure for camel-main
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch mm
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 636ab5c8c842f9b7bdfd67caa0e77737e7d1afae
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Nov 15 21:13:20 2023 +0100
CAMEL-20105: camel-micromemter - Make it easier to configure for camel-main
---
.../camel/component/micrometer/prometheus/MicrometerPrometheus.java | 2 ++
1 file changed, 2 insertions(+)
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 b6fee55cb02..36946b45423 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
@@ -43,6 +43,8 @@ public class MicrometerPrometheus extends ServiceSupport implements CamelMetrics
// TODO: option to configure prometheus
// TODO: context-path / port for http scrape service
+ // TODO: use platform-http-main
+ // TODO: dev console
private CamelContext camelContext;
private final PrometheusMeterRegistry meterRegistry = new PrometheusMeterRegistry(PrometheusConfig.DEFAULT);