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-spring-boot.git
The following commit(s) were added to refs/heads/main by this push:
new a806a9d8fe5 CAMEL-21649: camel-metrics - Add option to configure
InstrumentedThreadPoolFactory
a806a9d8fe5 is described below
commit a806a9d8fe5cadebf2f5782933c6795a2d9882f0
Author: Claus Ibsen <[email protected]>
AuthorDate: Fri Jan 24 09:41:33 2025 +0100
CAMEL-21649: camel-metrics - Add option to configure
InstrumentedThreadPoolFactory
---
.../camel-micrometer-starter/src/main/docs/micrometer.json | 7 +++++++
.../springboot/metrics/CamelMetricsAutoConfiguration.java | 8 ++++++++
.../springboot/metrics/CamelMetricsConfiguration.java | 14 ++++++++++++++
3 files changed, 29 insertions(+)
diff --git
a/components-starter/camel-micrometer-starter/src/main/docs/micrometer.json
b/components-starter/camel-micrometer-starter/src/main/docs/micrometer.json
index 28994b0bf95..7b7f0164e6b 100644
--- a/components-starter/camel-micrometer-starter/src/main/docs/micrometer.json
+++ b/components-starter/camel-micrometer-starter/src/main/docs/micrometer.json
@@ -56,6 +56,13 @@
"sourceType":
"org.apache.camel.component.micrometer.springboot.metrics.CamelMetricsConfiguration",
"defaultValue": true
},
+ {
+ "name": "camel.metrics.enable-instrumented-thread-pool-factory",
+ "type": "java.lang.Boolean",
+ "description": "Set whether to gather performance information about
Camel Thread Pools by injecting an InstrumentedThreadPoolFactory.",
+ "sourceType":
"org.apache.camel.component.micrometer.springboot.metrics.CamelMetricsConfiguration",
+ "defaultValue": false
+ },
{
"name": "camel.metrics.enable-message-history",
"type": "java.lang.Boolean",
diff --git
a/components-starter/camel-micrometer-starter/src/main/java/org/apache/camel/component/micrometer/springboot/metrics/CamelMetricsAutoConfiguration.java
b/components-starter/camel-micrometer-starter/src/main/java/org/apache/camel/component/micrometer/springboot/metrics/CamelMetricsAutoConfiguration.java
index f2525fe1d17..ec16dc028ef 100644
---
a/components-starter/camel-micrometer-starter/src/main/java/org/apache/camel/component/micrometer/springboot/metrics/CamelMetricsAutoConfiguration.java
+++
b/components-starter/camel-micrometer-starter/src/main/java/org/apache/camel/component/micrometer/springboot/metrics/CamelMetricsAutoConfiguration.java
@@ -26,6 +26,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.spi.ManagementStrategy;
import org.apache.camel.spring.boot.CamelAutoConfiguration;
import
org.apache.camel.spring.boot.util.ConditionalOnCamelContextAndAutoConfigurationBeans;
@@ -101,6 +102,13 @@ public class CamelMetricsAutoConfiguration {
}
camelContext.setMessageHistoryFactory(factory);
}
+
+ if (configuration.isEnableInstrumentedThreadPoolFactory()) {
+ InstrumentedThreadPoolFactory instrumentedThreadPoolFactory = new
InstrumentedThreadPoolFactory(
+ meterRegistry,
+
camelContext.getExecutorServiceManager().getThreadPoolFactory());
+
camelContext.getExecutorServiceManager().setThreadPoolFactory(instrumentedThreadPoolFactory);
+ }
}
}
\ No newline at end of file
diff --git
a/components-starter/camel-micrometer-starter/src/main/java/org/apache/camel/component/micrometer/springboot/metrics/CamelMetricsConfiguration.java
b/components-starter/camel-micrometer-starter/src/main/java/org/apache/camel/component/micrometer/springboot/metrics/CamelMetricsConfiguration.java
index dd3203b9351..7d37b6f7576 100644
---
a/components-starter/camel-micrometer-starter/src/main/java/org/apache/camel/component/micrometer/springboot/metrics/CamelMetricsConfiguration.java
+++
b/components-starter/camel-micrometer-starter/src/main/java/org/apache/camel/component/micrometer/springboot/metrics/CamelMetricsConfiguration.java
@@ -80,6 +80,12 @@ public class CamelMetricsConfiguration {
*/
private boolean enableRouteEventNotifier = true;
+ /**
+ * Set whether to gather performance information about Camel Thread Pools
by injecting an
+ * InstrumentedThreadPoolFactory.
+ */
+ private boolean enableInstrumentedThreadPoolFactory;
+
public boolean isUriTagEnabled() {
return uriTagEnabled;
}
@@ -151,4 +157,12 @@ public class CamelMetricsConfiguration {
public void setEnableRouteEventNotifier(boolean enableRouteEventNotifier) {
this.enableRouteEventNotifier = enableRouteEventNotifier;
}
+
+ public boolean isEnableInstrumentedThreadPoolFactory() {
+ return enableInstrumentedThreadPoolFactory;
+ }
+
+ public void setEnableInstrumentedThreadPoolFactory(boolean
enableInstrumentedThreadPoolFactory) {
+ this.enableInstrumentedThreadPoolFactory =
enableInstrumentedThreadPoolFactory;
+ }
}