This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch feature/CAMEL-24003-backlog-tracer-activity-queue in repository https://gitbox.apache.org/repos/asf/camel.git
commit a94705edcc044db33ca0476f98262529aa114f8c Author: Claus Ibsen <[email protected]> AuthorDate: Sun Jul 12 09:11:05 2026 +0200 CAMEL-24003: Add activityEnabled option to BacklogTracer Co-Authored-By: Claude Opus 4.6 <[email protected]> Signed-off-by: Claus Ibsen <[email protected]> --- .../main/camel-main-configuration-metadata.json | 1 + .../java/org/apache/camel/spi/BacklogTracer.java | 17 +++++++++++++++++ .../apache/camel/impl/debugger/BacklogTracer.java | 10 ++++++++++ .../camel/impl/console/ActivityDevConsole.java | 2 ++ .../TracerConfigurationPropertiesConfigurer.java | 7 +++++++ .../camel-main-configuration-metadata.json | 1 + core/camel-main/src/main/docs/main.adoc | 3 ++- .../org/apache/camel/main/BaseMainSupport.java | 1 + .../org/apache/camel/main/ProfileConfigurer.java | 2 ++ .../camel/main/TracerConfigurationProperties.java | 22 ++++++++++++++++++++++ .../mbean/ManagedBacklogTracerMBean.java | 6 ++++++ .../management/mbean/ManagedBacklogTracer.java | 10 ++++++++++ 12 files changed, 81 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 9c5e7a7718e5..996b4d992e3c 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 @@ -483,6 +483,7 @@ { "name": "camel.threadpool.poolSize", "required": false, "description": "Sets the default core pool size (threads to keep minimum in pool)", "sourceType": "org.apache.camel.main.ThreadPoolConfigurationProperties", "type": "integer", "javaType": "java.lang.Integer", "secret": false }, { "name": "camel.threadpool.rejectedPolicy", "required": false, "description": "Sets the default handler for tasks which cannot be executed by the thread pool.", "sourceType": "org.apache.camel.main.ThreadPoolConfigurationProperties", "type": "enum", "javaType": "org.apache.camel.util.concurrent.ThreadPoolRejectedPolicy", "secret": false, "enum": [ "Abort", "CallerRuns", "DiscardOldest", "Discard" ] }, { "name": "camel.threadpool.timeUnit", "required": false, "description": "Sets the default time unit used for keep alive time", "sourceType": "org.apache.camel.main.ThreadPoolConfigurationProperties", "type": "object", "javaType": "java.util.concurrent.TimeUnit", "secret": false }, + { "name": "camel.trace.activityEnabled", "required": false, "description": "Whether activity tracking is enabled. When enabled, the backlog tracer will capture activity data that can be enriched with additional details from tracing (such as span decorator attributes).", "sourceType": "org.apache.camel.main.TracerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": false, "secret": false }, { "name": "camel.trace.activitySize", "required": false, "description": "Defines how many completed exchange summaries to keep in the activity queue (should be between 1 - 1000). The activity queue captures lightweight metadata (no body or headers) each time an exchange completes a route, providing a rolling window of recent exchange activity.", "sourceType": "org.apache.camel.main.TracerConfigurationProperties", "type": "integer", "javaType": "int", "defaultValue": 100, "secret": false }, { "name": "camel.trace.backlogSize", "required": false, "description": "Defines how many of the last messages to keep in the tracer (should be between 1 - 1000).", "sourceType": "org.apache.camel.main.TracerConfigurationProperties", "type": "integer", "javaType": "int", "defaultValue": 100, "secret": false }, { "name": "camel.trace.bodyIncludeFiles", "required": false, "description": "Whether to include the message body of file based messages. The overhead is that the file content has to be read from the file.", "sourceType": "org.apache.camel.main.TracerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": true, "secret": false }, diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/BacklogTracer.java b/core/camel-api/src/main/java/org/apache/camel/spi/BacklogTracer.java index 5b7563ae8247..672087ba0f50 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/BacklogTracer.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/BacklogTracer.java @@ -43,6 +43,23 @@ import org.jspecify.annotations.Nullable; */ public interface BacklogTracer { + /** + * Whether the activity tracking feature is enabled. + * + * @since 4.22 + */ + default boolean isActivityEnabled() { + return false; + } + + /** + * To turn on or off the activity tracking feature. + * + * @since 4.22 + */ + default void setActivityEnabled(boolean activityEnabled) { + } + /** * Is the tracer enabled. */ diff --git a/core/camel-base-engine/src/main/java/org/apache/camel/impl/debugger/BacklogTracer.java b/core/camel-base-engine/src/main/java/org/apache/camel/impl/debugger/BacklogTracer.java index 29e77353857a..c716dfbcd11c 100644 --- a/core/camel-base-engine/src/main/java/org/apache/camel/impl/debugger/BacklogTracer.java +++ b/core/camel-base-engine/src/main/java/org/apache/camel/impl/debugger/BacklogTracer.java @@ -86,6 +86,7 @@ public class BacklogTracer extends ServiceSupport implements org.apache.camel.sp private boolean includeExchangeProperties = true; private boolean includeExchangeVariables = true; private boolean includeException = true; + private boolean activityEnabled; private boolean traceRests; private boolean traceTemplates; // a pattern to filter tracing nodes @@ -316,6 +317,11 @@ public class BacklogTracer extends ServiceSupport implements org.apache.camel.sp return predicate.matches(exchange); } + @Override + public boolean isActivityEnabled() { + return activityEnabled; + } + @Override public boolean isEnabled() { return enabled; @@ -689,6 +695,10 @@ public class BacklogTracer extends ServiceSupport implements org.apache.camel.sp return traceCounter.incrementAndGet(); } + public void setActivityEnabled(boolean activityEnabled) { + this.activityEnabled = activityEnabled; + } + @Override protected void doStart() throws Exception { camelContext.getManagementStrategy().addEventNotifier(activityEventNotifier); diff --git a/core/camel-console/src/main/java/org/apache/camel/impl/console/ActivityDevConsole.java b/core/camel-console/src/main/java/org/apache/camel/impl/console/ActivityDevConsole.java index 4082259daafa..e126c5a3ae45 100644 --- a/core/camel-console/src/main/java/org/apache/camel/impl/console/ActivityDevConsole.java +++ b/core/camel-console/src/main/java/org/apache/camel/impl/console/ActivityDevConsole.java @@ -39,6 +39,7 @@ public class ActivityDevConsole extends AbstractDevConsole { BacklogTracer tracer = getCamelContext().getCamelContextExtension().getContextPlugin(BacklogTracer.class); if (tracer != null) { + sb.append("Activity Enabled: ").append(tracer.isActivityEnabled()).append("\n"); sb.append("Activity Size: ").append(tracer.getActivitySize()).append("\n"); for (BacklogTracerActivityMessage event : tracer.getActivity()) { sb.append(String.format(" %s | %s | %s | %dms | %s", @@ -64,6 +65,7 @@ public class ActivityDevConsole extends AbstractDevConsole { BacklogTracer tracer = getCamelContext().getCamelContextExtension().getContextPlugin(BacklogTracer.class); if (tracer != null) { + root.put("activityEnabled", tracer.isActivityEnabled()); root.put("activitySize", tracer.getActivitySize()); JsonArray arr = new JsonArray(); diff --git a/core/camel-main/src/generated/java/org/apache/camel/main/TracerConfigurationPropertiesConfigurer.java b/core/camel-main/src/generated/java/org/apache/camel/main/TracerConfigurationPropertiesConfigurer.java index 811931a0aad8..ddb0b731980a 100644 --- a/core/camel-main/src/generated/java/org/apache/camel/main/TracerConfigurationPropertiesConfigurer.java +++ b/core/camel-main/src/generated/java/org/apache/camel/main/TracerConfigurationPropertiesConfigurer.java @@ -22,6 +22,7 @@ public class TracerConfigurationPropertiesConfigurer extends org.apache.camel.su private static final Map<String, Object> ALL_OPTIONS; static { Map<String, Object> map = new CaseInsensitiveMap(); + map.put("ActivityEnabled", boolean.class); map.put("ActivitySize", int.class); map.put("BacklogSize", int.class); map.put("BodyIncludeFiles", boolean.class); @@ -44,6 +45,8 @@ public class TracerConfigurationPropertiesConfigurer extends org.apache.camel.su public boolean configure(CamelContext camelContext, Object obj, String name, Object value, boolean ignoreCase) { org.apache.camel.main.TracerConfigurationProperties target = (org.apache.camel.main.TracerConfigurationProperties) obj; switch (ignoreCase ? name.toLowerCase() : name) { + case "activityenabled": + case "activityEnabled": target.setActivityEnabled(property(camelContext, boolean.class, value)); return true; case "activitysize": case "activitySize": target.setActivitySize(property(camelContext, int.class, value)); return true; case "backlogsize": @@ -84,6 +87,8 @@ public class TracerConfigurationPropertiesConfigurer extends org.apache.camel.su @Override public Class<?> getOptionType(String name, boolean ignoreCase) { switch (ignoreCase ? name.toLowerCase() : name) { + case "activityenabled": + case "activityEnabled": return boolean.class; case "activitysize": case "activitySize": return int.class; case "backlogsize": @@ -120,6 +125,8 @@ public class TracerConfigurationPropertiesConfigurer extends org.apache.camel.su public Object getOptionValue(Object obj, String name, boolean ignoreCase) { org.apache.camel.main.TracerConfigurationProperties target = (org.apache.camel.main.TracerConfigurationProperties) obj; switch (ignoreCase ? name.toLowerCase() : name) { + case "activityenabled": + case "activityEnabled": return target.isActivityEnabled(); case "activitysize": case "activitySize": return target.getActivitySize(); case "backlogsize": 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 9c5e7a7718e5..996b4d992e3c 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 @@ -483,6 +483,7 @@ { "name": "camel.threadpool.poolSize", "required": false, "description": "Sets the default core pool size (threads to keep minimum in pool)", "sourceType": "org.apache.camel.main.ThreadPoolConfigurationProperties", "type": "integer", "javaType": "java.lang.Integer", "secret": false }, { "name": "camel.threadpool.rejectedPolicy", "required": false, "description": "Sets the default handler for tasks which cannot be executed by the thread pool.", "sourceType": "org.apache.camel.main.ThreadPoolConfigurationProperties", "type": "enum", "javaType": "org.apache.camel.util.concurrent.ThreadPoolRejectedPolicy", "secret": false, "enum": [ "Abort", "CallerRuns", "DiscardOldest", "Discard" ] }, { "name": "camel.threadpool.timeUnit", "required": false, "description": "Sets the default time unit used for keep alive time", "sourceType": "org.apache.camel.main.ThreadPoolConfigurationProperties", "type": "object", "javaType": "java.util.concurrent.TimeUnit", "secret": false }, + { "name": "camel.trace.activityEnabled", "required": false, "description": "Whether activity tracking is enabled. When enabled, the backlog tracer will capture activity data that can be enriched with additional details from tracing (such as span decorator attributes).", "sourceType": "org.apache.camel.main.TracerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": false, "secret": false }, { "name": "camel.trace.activitySize", "required": false, "description": "Defines how many completed exchange summaries to keep in the activity queue (should be between 1 - 1000). The activity queue captures lightweight metadata (no body or headers) each time an exchange completes a route, providing a rolling window of recent exchange activity.", "sourceType": "org.apache.camel.main.TracerConfigurationProperties", "type": "integer", "javaType": "int", "defaultValue": 100, "secret": false }, { "name": "camel.trace.backlogSize", "required": false, "description": "Defines how many of the last messages to keep in the tracer (should be between 1 - 1000).", "sourceType": "org.apache.camel.main.TracerConfigurationProperties", "type": "integer", "javaType": "int", "defaultValue": 100, "secret": false }, { "name": "camel.trace.bodyIncludeFiles", "required": false, "description": "Whether to include the message body of file based messages. The overhead is that the file content has to be read from the file.", "sourceType": "org.apache.camel.main.TracerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": true, "secret": false }, diff --git a/core/camel-main/src/main/docs/main.adoc b/core/camel-main/src/main/docs/main.adoc index f19111d9f174..684b463909f9 100644 --- a/core/camel-main/src/main/docs/main.adoc +++ b/core/camel-main/src/main/docs/main.adoc @@ -282,11 +282,12 @@ The camel.debug supports 15 options, which are listed below. === Camel Tracer configurations -The camel.trace supports 15 options, which are listed below. +The camel.trace supports 16 options, which are listed below. [width="100%",cols="2,5,^1,2",options="header"] |=== | Name | Description | Default | Type +| *camel.trace.activityEnabled* | Whether activity tracking is enabled. When enabled, the backlog tracer will capture activity data that can be enriched with additional details from tracing (such as span decorator attributes). | false | boolean | *camel.trace.activitySize* | Defines how many completed exchange summaries to keep in the activity queue (should be between 1 - 1000). The activity queue captures lightweight metadata (no body or headers) each time an exchange completes a route, providing a rolling window of recent exchange activity. | 100 | int | *camel.trace.backlogSize* | Defines how many of the last messages to keep in the tracer (should be between 1 - 1000). | 100 | int | *camel.trace.bodyIncludeFiles* | Whether to include the message body of file based messages. The overhead is that the file content has to be read from the file. | true | boolean 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 26ce5b2e0bb7..977fdeafce89 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 @@ -2504,6 +2504,7 @@ public abstract class BaseMainSupport extends BaseService { tracer.setStandby(config.isStandby()); tracer.setBacklogSize(config.getBacklogSize()); tracer.setActivitySize(config.getActivitySize()); + tracer.setActivityEnabled(config.isActivityEnabled()); tracer.setRemoveOnDump(config.isRemoveOnDump()); tracer.setBodyMaxChars(config.getBodyMaxChars()); tracer.setBodyIncludeStreams(config.isBodyIncludeStreams()); diff --git a/core/camel-main/src/main/java/org/apache/camel/main/ProfileConfigurer.java b/core/camel-main/src/main/java/org/apache/camel/main/ProfileConfigurer.java index 6abe909806b5..209d7595328d 100644 --- a/core/camel-main/src/main/java/org/apache/camel/main/ProfileConfigurer.java +++ b/core/camel-main/src/main/java/org/apache/camel/main/ProfileConfigurer.java @@ -54,6 +54,8 @@ public class ProfileConfigurer { if (!enabled) { config.tracerConfig().withStandby(true); } + // enable activity tracking so backlog tracer captures enriched data + config.tracerConfig().withActivityEnabled(true); // enable error registry to capture routing errors config.errorRegistryConfig().withEnabled(true); // dev profile allows insecure:dev options by default since those features diff --git a/core/camel-main/src/main/java/org/apache/camel/main/TracerConfigurationProperties.java b/core/camel-main/src/main/java/org/apache/camel/main/TracerConfigurationProperties.java index de5e6939c335..7f92e10dc413 100644 --- a/core/camel-main/src/main/java/org/apache/camel/main/TracerConfigurationProperties.java +++ b/core/camel-main/src/main/java/org/apache/camel/main/TracerConfigurationProperties.java @@ -32,6 +32,8 @@ public class TracerConfigurationProperties implements BootstrapCloseable { private boolean enabled; @Metadata private boolean standby; + @Metadata + private boolean activityEnabled; @Metadata(label = "advanced", defaultValue = "100") private int backlogSize = 100; @Metadata(label = "advanced", defaultValue = "100") @@ -95,6 +97,18 @@ public class TracerConfigurationProperties implements BootstrapCloseable { this.standby = standby; } + public boolean isActivityEnabled() { + return activityEnabled; + } + + /** + * Whether activity tracking is enabled. When enabled, the backlog tracer will capture activity data that can be + * enriched with additional details from tracing (such as span decorator attributes). + */ + public void setActivityEnabled(boolean activityEnabled) { + this.activityEnabled = activityEnabled; + } + public int getBacklogSize() { return backlogSize; } @@ -260,6 +274,14 @@ public class TracerConfigurationProperties implements BootstrapCloseable { return this; } + /** + * Whether activity tracking is enabled. + */ + public TracerConfigurationProperties withActivityEnabled(boolean activityEnabled) { + this.activityEnabled = activityEnabled; + return this; + } + /** * Defines how many of the last messages to keep in the tracer (should be between 1 - 1000). */ diff --git a/core/camel-management-api/src/main/java/org/apache/camel/api/management/mbean/ManagedBacklogTracerMBean.java b/core/camel-management-api/src/main/java/org/apache/camel/api/management/mbean/ManagedBacklogTracerMBean.java index 2e63926b8bd7..f3d8364fdbd7 100644 --- a/core/camel-management-api/src/main/java/org/apache/camel/api/management/mbean/ManagedBacklogTracerMBean.java +++ b/core/camel-management-api/src/main/java/org/apache/camel/api/management/mbean/ManagedBacklogTracerMBean.java @@ -39,6 +39,12 @@ public interface ManagedBacklogTracerMBean { @ManagedAttribute(description = "Is tracing enabled") void setEnabled(boolean enabled); + @ManagedAttribute(description = "Whether activity tracking is enabled") + boolean isActivityEnabled(); + + @ManagedAttribute(description = "Whether activity tracking is enabled") + void setActivityEnabled(boolean activityEnabled); + @ManagedAttribute(description = "Number of maximum traced messages in total to keep in the backlog (FIFO queue)") int getBacklogSize(); diff --git a/core/camel-management/src/main/java/org/apache/camel/management/mbean/ManagedBacklogTracer.java b/core/camel-management/src/main/java/org/apache/camel/management/mbean/ManagedBacklogTracer.java index bd449b0d4134..619f9bb30f0c 100644 --- a/core/camel-management/src/main/java/org/apache/camel/management/mbean/ManagedBacklogTracer.java +++ b/core/camel-management/src/main/java/org/apache/camel/management/mbean/ManagedBacklogTracer.java @@ -76,6 +76,16 @@ public class ManagedBacklogTracer implements ManagedBacklogTracerMBean { return backlogTracer.isEnabled(); } + @Override + public boolean isActivityEnabled() { + return backlogTracer.isActivityEnabled(); + } + + @Override + public void setActivityEnabled(boolean activityEnabled) { + backlogTracer.setActivityEnabled(activityEnabled); + } + @Override public int getBacklogSize() { return backlogTracer.getBacklogSize();
