This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new b8f7e476965 CAMEL-21649: camel-metrics - Add option to configure
InstrumentedThreadPoolFactory
b8f7e476965 is described below
commit b8f7e4769656134f86786bb543af23420a7ce0cf
Author: Claus Ibsen <[email protected]>
AuthorDate: Fri Jan 24 09:37:15 2025 +0100
CAMEL-21649: camel-metrics - Add option to configure
InstrumentedThreadPoolFactory
---
.../main/camel-main-configuration-metadata.json | 1 +
.../prometheus/MicrometerPrometheusConfigurer.java | 6 ++++++
.../prometheus/MicrometerPrometheus.java | 22 ++++++++++++++++++++++
.../MetricsConfigurationPropertiesConfigurer.java | 7 +++++++
.../camel-main-configuration-metadata.json | 1 +
core/camel-main/src/main/docs/main.adoc | 3 ++-
.../camel/main/MetricsConfigurationProperties.java | 21 +++++++++++++++++++++
7 files changed, 60 insertions(+), 1 deletion(-)
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 5d75bf53c2a..ef2a4f79f63 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
@@ -190,6 +190,7 @@
{ "name": "camel.metrics.clearOnReload", "description": "Clear the
captured metrics data when Camel is reloading routes such as when using Camel
JBang.", "sourceType": "org.apache.camel.main.MetricsConfigurationProperties",
"type": "boolean", "javaType": "boolean", "defaultValue": true },
{ "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.enableInstrumentedThreadPoolFactory",
"description": "Set whether to gather performance information about Camel
Thread Pools by injecting an InstrumentedThreadPoolFactory.", "sourceType":
"org.apache.camel.main.MetricsConfigurationProperties", "type": "boolean",
"javaType": "boolean", "defaultValue": false },
{ "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 },
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 265a436b053..d3747fd89e7 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
@@ -30,6 +30,8 @@ public class MicrometerPrometheusConfigurer extends
org.apache.camel.support.com
case "clearOnReload": target.setClearOnReload(property(camelContext,
boolean.class, value)); return true;
case "enableexchangeeventnotifier":
case "enableExchangeEventNotifier":
target.setEnableExchangeEventNotifier(property(camelContext, boolean.class,
value)); return true;
+ case "enableinstrumentedthreadpoolfactory":
+ case "enableInstrumentedThreadPoolFactory":
target.setEnableInstrumentedThreadPoolFactory(property(camelContext,
boolean.class, value)); return true;
case "enablemessagehistory":
case "enableMessageHistory":
target.setEnableMessageHistory(property(camelContext, boolean.class, value));
return true;
case "enablerouteeventnotifier":
@@ -57,6 +59,8 @@ public class MicrometerPrometheusConfigurer extends
org.apache.camel.support.com
case "clearOnReload": return boolean.class;
case "enableexchangeeventnotifier":
case "enableExchangeEventNotifier": return boolean.class;
+ case "enableinstrumentedthreadpoolfactory":
+ case "enableInstrumentedThreadPoolFactory": return boolean.class;
case "enablemessagehistory":
case "enableMessageHistory": return boolean.class;
case "enablerouteeventnotifier":
@@ -85,6 +89,8 @@ public class MicrometerPrometheusConfigurer extends
org.apache.camel.support.com
case "clearOnReload": return target.isClearOnReload();
case "enableexchangeeventnotifier":
case "enableExchangeEventNotifier": return
target.isEnableExchangeEventNotifier();
+ case "enableinstrumentedthreadpoolfactory":
+ case "enableInstrumentedThreadPoolFactory": return
target.isEnableInstrumentedThreadPoolFactory();
case "enablemessagehistory":
case "enableMessageHistory": return target.isEnableMessageHistory();
case "enablerouteeventnotifier":
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 fa8b3d54152..f29b08e8a7d 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
@@ -47,6 +47,7 @@ import
org.apache.camel.component.micrometer.messagehistory.MicrometerMessageHis
import
org.apache.camel.component.micrometer.messagehistory.MicrometerMessageHistoryNamingStrategy;
import
org.apache.camel.component.micrometer.routepolicy.MicrometerRoutePolicyFactory;
import
org.apache.camel.component.micrometer.routepolicy.MicrometerRoutePolicyNamingStrategy;
+import org.apache.camel.component.micrometer.spi.InstrumentedThreadPoolFactory;
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;
@@ -95,6 +96,8 @@ public class MicrometerPrometheus extends ServiceSupport
implements CamelMetrics
private boolean enableExchangeEventNotifier = true;
@Metadata(defaultValue = "true")
private boolean enableRouteEventNotifier = true;
+ @Metadata(defaultValue = "false")
+ private boolean enableInstrumentedThreadPoolFactory;
@Metadata(defaultValue = "true")
private boolean clearOnReload = true;
@Metadata(defaultValue = "0.0.4", enums = "0.0.4,1.0.0")
@@ -187,6 +190,18 @@ public class MicrometerPrometheus extends ServiceSupport
implements CamelMetrics
this.enableRouteEventNotifier = enableRouteEventNotifier;
}
+ public boolean isEnableInstrumentedThreadPoolFactory() {
+ return enableInstrumentedThreadPoolFactory;
+ }
+
+ /**
+ * Set whether to gather performance information about Camel Thread Pools
by injecting an
+ * InstrumentedThreadPoolFactory.
+ */
+ public void setEnableInstrumentedThreadPoolFactory(boolean
enableInstrumentedThreadPoolFactory) {
+ this.enableInstrumentedThreadPoolFactory =
enableInstrumentedThreadPoolFactory;
+ }
+
public boolean isClearOnReload() {
return clearOnReload;
}
@@ -316,6 +331,13 @@ public class MicrometerPrometheus extends ServiceSupport
implements CamelMetrics
camelContext.setMessageHistoryFactory(factory);
}
+ if (isEnableInstrumentedThreadPoolFactory()) {
+ InstrumentedThreadPoolFactory instrumentedThreadPoolFactory = new
InstrumentedThreadPoolFactory(
+ meterRegistry,
+
camelContext.getExecutorServiceManager().getThreadPoolFactory());
+
camelContext.getExecutorServiceManager().setThreadPoolFactory(instrumentedThreadPoolFactory);
+ }
+
if (clearOnReload) {
camelContext.getManagementStrategy().addEventNotifier(new
SimpleEventNotifierSupport() {
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 d3d2739b918..bd05608129b 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
@@ -25,6 +25,7 @@ public class MetricsConfigurationPropertiesConfigurer extends
org.apache.camel.s
map.put("Binders", java.lang.String.class);
map.put("ClearOnReload", boolean.class);
map.put("EnableExchangeEventNotifier", boolean.class);
+ map.put("EnableInstrumentedThreadPoolFactory", boolean.class);
map.put("EnableMessageHistory", boolean.class);
map.put("EnableRouteEventNotifier", boolean.class);
map.put("EnableRoutePolicy", boolean.class);
@@ -45,6 +46,8 @@ public class MetricsConfigurationPropertiesConfigurer extends
org.apache.camel.s
case "clearOnReload": target.setClearOnReload(property(camelContext,
boolean.class, value)); return true;
case "enableexchangeeventnotifier":
case "enableExchangeEventNotifier":
target.setEnableExchangeEventNotifier(property(camelContext, boolean.class,
value)); return true;
+ case "enableinstrumentedthreadpoolfactory":
+ case "enableInstrumentedThreadPoolFactory":
target.setEnableInstrumentedThreadPoolFactory(property(camelContext,
boolean.class, value)); return true;
case "enablemessagehistory":
case "enableMessageHistory":
target.setEnableMessageHistory(property(camelContext, boolean.class, value));
return true;
case "enablerouteeventnotifier":
@@ -76,6 +79,8 @@ public class MetricsConfigurationPropertiesConfigurer extends
org.apache.camel.s
case "clearOnReload": return boolean.class;
case "enableexchangeeventnotifier":
case "enableExchangeEventNotifier": return boolean.class;
+ case "enableinstrumentedthreadpoolfactory":
+ case "enableInstrumentedThreadPoolFactory": return boolean.class;
case "enablemessagehistory":
case "enableMessageHistory": return boolean.class;
case "enablerouteeventnotifier":
@@ -103,6 +108,8 @@ public class MetricsConfigurationPropertiesConfigurer
extends org.apache.camel.s
case "clearOnReload": return target.isClearOnReload();
case "enableexchangeeventnotifier":
case "enableExchangeEventNotifier": return
target.isEnableExchangeEventNotifier();
+ case "enableinstrumentedthreadpoolfactory":
+ case "enableInstrumentedThreadPoolFactory": return
target.isEnableInstrumentedThreadPoolFactory();
case "enablemessagehistory":
case "enableMessageHistory": return target.isEnableMessageHistory();
case "enablerouteeventnotifier":
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 5d75bf53c2a..ef2a4f79f63 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
@@ -190,6 +190,7 @@
{ "name": "camel.metrics.clearOnReload", "description": "Clear the
captured metrics data when Camel is reloading routes such as when using Camel
JBang.", "sourceType": "org.apache.camel.main.MetricsConfigurationProperties",
"type": "boolean", "javaType": "boolean", "defaultValue": true },
{ "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.enableInstrumentedThreadPoolFactory",
"description": "Set whether to gather performance information about Camel
Thread Pools by injecting an InstrumentedThreadPoolFactory.", "sourceType":
"org.apache.camel.main.MetricsConfigurationProperties", "type": "boolean",
"javaType": "boolean", "defaultValue": false },
{ "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 },
diff --git a/core/camel-main/src/main/docs/main.adoc
b/core/camel-main/src/main/docs/main.adoc
index b771efc13b8..c4a41bb9cb4 100644
--- a/core/camel-main/src/main/docs/main.adoc
+++ b/core/camel-main/src/main/docs/main.adoc
@@ -480,7 +480,7 @@ The camel.opentelemetry supports 5 options, which are
listed below.
=== Camel Micrometer Metrics configurations
-The camel.metrics supports 11 options, which are listed below.
+The camel.metrics supports 12 options, which are listed below.
[width="100%",cols="2,5,^1,2",options="header"]
|===
@@ -489,6 +489,7 @@ The camel.metrics supports 11 options, which are listed
below.
| *camel.metrics.clearOnReload* | Clear the captured metrics data when Camel
is reloading routes such as when using Camel JBang. | true | boolean
| *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.enable{zwsp}InstrumentedThreadPoolFactory* | Set whether to
gather performance information about Camel Thread Pools by injecting an
InstrumentedThreadPoolFactory. | false | 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
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 cd3a206c87a..02e9b96c78d 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
@@ -40,6 +40,8 @@ public class MetricsConfigurationProperties implements
BootstrapCloseable {
private boolean enableExchangeEventNotifier = true;
@Metadata(defaultValue = "true")
private boolean enableRouteEventNotifier = true;
+ @Metadata(defaultValue = "false")
+ private boolean enableInstrumentedThreadPoolFactory;
@Metadata(defaultValue = "true")
private boolean clearOnReload = true;
@Metadata(defaultValue = "0.0.4", enums = "0.0.4,1.0.0")
@@ -141,6 +143,17 @@ public class MetricsConfigurationProperties implements
BootstrapCloseable {
this.enableRouteEventNotifier = enableRouteEventNotifier;
}
+ public boolean isEnableInstrumentedThreadPoolFactory() {
+ return enableInstrumentedThreadPoolFactory;
+ }
+
+ /**
+ * Set whether to gather performance information about Camel Thread Pools
by injecting an InstrumentedThreadPoolFactory.
+ */
+ public void setEnableInstrumentedThreadPoolFactory(boolean
enableInstrumentedThreadPoolFactory) {
+ this.enableInstrumentedThreadPoolFactory =
enableInstrumentedThreadPoolFactory;
+ }
+
public boolean isClearOnReload() {
return clearOnReload;
}
@@ -261,6 +274,14 @@ public class MetricsConfigurationProperties implements
BootstrapCloseable {
return this;
}
+ /**
+ * Set whether to gather performance information about Camel Thread Pools
by injecting an InstrumentedThreadPoolFactory.
+ */
+ public MetricsConfigurationProperties
withEnableInstrumentedThreadPoolFactory(boolean
enableInstrumentedThreadPoolFactory) {
+ this.enableInstrumentedThreadPoolFactory =
enableInstrumentedThreadPoolFactory;
+ return this;
+ }
+
/**
* Clear the captured metrics data when Camel is reloading routes such as
when using Camel JBang.
*/