This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch group-debug in repository https://gitbox.apache.org/repos/asf/camel.git
commit 163172433cb7881f9287552a75c5d7b9db60f8dc Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Thu Feb 29 19:22:20 2024 +0100 CAMEL-20472: camel-main - Add group for configuring tracing --- .../main/camel-main-configuration-metadata.json | 18 +- .../MainConfigurationPropertiesConfigurer.java | 18 -- .../TracerConfigurationPropertiesConfigurer.java | 127 ++++++++ .../camel-main-configuration-metadata.json | 18 +- ...apache.camel.main.TracerConfigurationProperties | 2 + core/camel-main/src/main/docs/main.adoc | 28 +- .../org/apache/camel/main/BaseMainSupport.java | 55 ++++ .../camel/main/DefaultConfigurationConfigurer.java | 3 - .../camel/main/DefaultConfigurationProperties.java | 76 ----- .../camel/main/MainConfigurationProperties.java | 23 ++ .../camel/main/TracerConfigurationProperties.java | 347 +++++++++++++++++++++ .../ROOT/pages/camel-4x-upgrade-guide-4_5.adoc | 7 + .../java/org/apache/camel/main/KameletMain.java | 2 +- .../maven/packaging/PrepareCamelMainMojo.java | 6 + 14 files changed, 622 insertions(+), 108 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 387d0a54077..1f763aafe27 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 @@ -4,6 +4,7 @@ { "name": "camel.routecontroller", "description": "Camel Route Controller configurations", "sourceType": "org.apache.camel.main.RouteControllerConfigurationProperties" }, { "name": "camel.server", "description": "Camel Embedded HTTP Server (only for standalone; not Spring Boot or Quarkus) configurations", "sourceType": "org.apache.camel.main.HttpServerConfigurationProperties" }, { "name": "camel.debug", "description": "Camel Debugger configurations", "sourceType": "org.apache.camel.main.DebuggerConfigurationProperties" }, + { "name": "camel.trace", "description": "Camel Tracer configurations", "sourceType": "org.apache.camel.main.TracerConfigurationProperties" }, { "name": "camel.ssl", "description": "Camel SSL configurations", "sourceType": "org.apache.camel.main.SSLConfigurationProperties" }, { "name": "camel.threadpool", "description": "Camel Thread Pool configurations", "sourceType": "org.apache.camel.main.ThreadPoolConfigurationProperties" }, { "name": "camel.health", "description": "Camel Health Check configurations", "sourceType": "org.apache.camel.main.HealthConfigurationProperties" }, @@ -26,9 +27,6 @@ { "name": "camel.main.autoConfigurationSystemPropertiesEnabled", "description": "Whether auto configuration should include JVM system properties as well. When enabled this allows to overrule any configuration using a JVM system property. For example to set a shutdown timeout of 5 seconds: -D camel.main.shutdown-timeout=5. Note that JVM system properties take precedence over OS environment variables. This option is default enabled.", "sourceType": "org.apache.camel.main.MainConfigurat [...] { "name": "camel.main.autoStartup", "description": "Sets whether the object should automatically start when Camel starts. Important: Currently only routes can be disabled, as CamelContext's are always started. Note: When setting auto startup false on CamelContext then that takes precedence and no routes are started. You would need to start CamelContext explicit using the org.apache.camel.CamelContext.start() method, to start the context, and then you would need to start the routes ma [...] { "name": "camel.main.autowiredEnabled", "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc. Default is true.", "sourceType": "org.apache.camel.main.DefaultConfiguration [...] - { "name": "camel.main.backlogTracing", "description": "Sets whether backlog tracing is enabled or not. Default is false.", "sourceType": "org.apache.camel.main.DefaultConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" }, - { "name": "camel.main.backlogTracingStandby", "description": "Whether to set backlog tracing on standby. If on standby then the backlog tracer is installed and made available. Then the backlog tracer can be enabled later at runtime via JMX or via Java API. Default is false.", "sourceType": "org.apache.camel.main.DefaultConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" }, - { "name": "camel.main.backlogTracingTemplates", "description": "Whether backlog tracing should trace inner details from route templates (or kamelets). Turning this on increases the verbosity of tracing by including events from internal routes in the templates or kamelets. Default is false.", "sourceType": "org.apache.camel.main.DefaultConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" }, { "name": "camel.main.basePackageScan", "description": "Package name to use as base (offset) for classpath scanning of RouteBuilder , org.apache.camel.TypeConverter , CamelConfiguration classes, and also classes annotated with org.apache.camel.Converter , or org.apache.camel.BindToRegistry . If you are using Spring Boot then it is instead recommended to use Spring Boots component scanning and annotate your route builder classes with Component. In other words only use this for Camel M [...] { "name": "camel.main.basePackageScanEnabled", "description": "Whether base package scan is enabled.", "sourceType": "org.apache.camel.main.MainConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": true }, { "name": "camel.main.beanIntrospectionExtendedStatistics", "description": "Sets whether bean introspection uses extended statistics. The default is false.", "sourceType": "org.apache.camel.main.DefaultConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" }, @@ -276,6 +274,20 @@ { "name": "camel.threadpool.poolSize", "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" }, { "name": "camel.threadpool.rejectedPolicy", "description": "Sets the default handler for tasks which cannot be executed by the thread pool.", "sourceType": "org.apache.camel.main.ThreadPoolConfigurationProperties", "type": "object", "javaType": "org.apache.camel.util.concurrent.ThreadPoolRejectedPolicy", "enum": [ "Abort", "CallerRuns", "DiscardOldest", "Discard" ] }, { "name": "camel.threadpool.timeUnit", "description": "Sets the default time unit used for keep alive time", "sourceType": "org.apache.camel.main.ThreadPoolConfigurationProperties", "type": "object", "javaType": "java.util.concurrent.TimeUnit" }, + { "name": "camel.trace.backlogSize", "description": "Defines how many of the last messages to keep in the tracer.", "sourceType": "org.apache.camel.main.TracerConfigurationProperties", "type": "integer", "javaType": "int", "defaultValue": 1000 }, + { "name": "camel.trace.bodyIncludeFiles", "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 }, + { "name": "camel.trace.bodyIncludeStreams", "description": "Whether to include the message body of stream based messages. If enabled then beware the stream may not be re-readable later. See more about Stream Caching.", "sourceType": "org.apache.camel.main.TracerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" }, + { "name": "camel.trace.bodyMaxChars", "description": "To limit the message body to a maximum size in the traced message. Use 0 or negative value to use unlimited size.", "sourceType": "org.apache.camel.main.TracerConfigurationProperties", "type": "integer", "javaType": "int", "defaultValue": 131072 }, + { "name": "camel.trace.enabled", "description": "Enables tracer in your Camel application.", "sourceType": "org.apache.camel.main.TracerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" }, + { "name": "camel.trace.includeException", "description": "Trace messages to include exception if the message failed", "sourceType": "org.apache.camel.main.TracerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": true }, + { "name": "camel.trace.includeExchangeProperties", "description": "Whether to include the exchange properties in the traced message", "sourceType": "org.apache.camel.main.TracerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": true }, + { "name": "camel.trace.includeExchangeVariables", "description": "Whether to include the exchange variables in the traced message", "sourceType": "org.apache.camel.main.TracerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": true }, + { "name": "camel.trace.removeOnDump", "description": "Whether all traced messages should be removed when the tracer is dumping. By default, the messages are removed, which means that dumping will not contain previous dumped messages.", "sourceType": "org.apache.camel.main.TracerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": true }, + { "name": "camel.trace.standby", "description": "To set the tracer in standby mode, where the tracer will be installed by not automatic enabled. The tracer can then later be enabled explicit from Java, JMX or tooling.", "sourceType": "org.apache.camel.main.TracerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" }, + { "name": "camel.trace.traceFilter", "description": "Filter for tracing messages", "sourceType": "org.apache.camel.main.TracerConfigurationProperties", "type": "string", "javaType": "java.lang.String" }, + { "name": "camel.trace.tracePattern", "description": "Filter for tracing by route or node id", "sourceType": "org.apache.camel.main.TracerConfigurationProperties", "type": "string", "javaType": "java.lang.String" }, + { "name": "camel.trace.traceRests", "description": "Whether to trace routes that is created from Rest DSL.", "sourceType": "org.apache.camel.main.TracerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" }, + { "name": "camel.trace.traceTemplates", "description": "Whether to trace routes that is created from route templates or kamelets.", "sourceType": "org.apache.camel.main.TracerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" }, { "name": "camel.vault.aws.accessKey", "description": "The AWS access key", "sourceType": "org.apache.camel.vault.AwsVaultConfiguration", "type": "string", "javaType": "java.lang.String" }, { "name": "camel.vault.aws.defaultCredentialsProvider", "description": "Define if we want to use the AWS Default Credentials Provider or not", "sourceType": "org.apache.camel.vault.AwsVaultConfiguration", "type": "boolean", "javaType": "boolean", "defaultValue": "false" }, { "name": "camel.vault.aws.profileCredentialsProvider", "description": "Define if we want to use the AWS Profile Credentials Provider or not", "sourceType": "org.apache.camel.vault.AwsVaultConfiguration", "type": "boolean", "javaType": "boolean", "defaultValue": "false" }, diff --git a/core/camel-main/src/generated/java/org/apache/camel/main/MainConfigurationPropertiesConfigurer.java b/core/camel-main/src/generated/java/org/apache/camel/main/MainConfigurationPropertiesConfigurer.java index 7d2f91e74db..c47d98469da 100644 --- a/core/camel-main/src/generated/java/org/apache/camel/main/MainConfigurationPropertiesConfigurer.java +++ b/core/camel-main/src/generated/java/org/apache/camel/main/MainConfigurationPropertiesConfigurer.java @@ -37,12 +37,6 @@ public class MainConfigurationPropertiesConfigurer extends org.apache.camel.supp case "AutoStartup": target.setAutoStartup(property(camelContext, boolean.class, value)); return true; case "autowiredenabled": case "AutowiredEnabled": target.setAutowiredEnabled(property(camelContext, boolean.class, value)); return true; - case "backlogtracing": - case "BacklogTracing": target.setBacklogTracing(property(camelContext, boolean.class, value)); return true; - case "backlogtracingstandby": - case "BacklogTracingStandby": target.setBacklogTracingStandby(property(camelContext, boolean.class, value)); return true; - case "backlogtracingtemplates": - case "BacklogTracingTemplates": target.setBacklogTracingTemplates(property(camelContext, boolean.class, value)); return true; case "basepackagescan": case "BasePackageScan": target.setBasePackageScan(property(camelContext, java.lang.String.class, value)); return true; case "basepackagescanenabled": @@ -282,12 +276,6 @@ public class MainConfigurationPropertiesConfigurer extends org.apache.camel.supp case "AutoStartup": return boolean.class; case "autowiredenabled": case "AutowiredEnabled": return boolean.class; - case "backlogtracing": - case "BacklogTracing": return boolean.class; - case "backlogtracingstandby": - case "BacklogTracingStandby": return boolean.class; - case "backlogtracingtemplates": - case "BacklogTracingTemplates": return boolean.class; case "basepackagescan": case "BasePackageScan": return java.lang.String.class; case "basepackagescanenabled": @@ -528,12 +516,6 @@ public class MainConfigurationPropertiesConfigurer extends org.apache.camel.supp case "AutoStartup": return target.isAutoStartup(); case "autowiredenabled": case "AutowiredEnabled": return target.isAutowiredEnabled(); - case "backlogtracing": - case "BacklogTracing": return target.isBacklogTracing(); - case "backlogtracingstandby": - case "BacklogTracingStandby": return target.isBacklogTracingStandby(); - case "backlogtracingtemplates": - case "BacklogTracingTemplates": return target.isBacklogTracingTemplates(); case "basepackagescan": case "BasePackageScan": return target.getBasePackageScan(); case "basepackagescanenabled": 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 new file mode 100644 index 00000000000..951ea669e19 --- /dev/null +++ b/core/camel-main/src/generated/java/org/apache/camel/main/TracerConfigurationPropertiesConfigurer.java @@ -0,0 +1,127 @@ +/* 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.TracerConfigurationProperties; + +/** + * Generated by camel build tools - do NOT edit this file! + */ +@SuppressWarnings("unchecked") +public class TracerConfigurationPropertiesConfigurer 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.TracerConfigurationProperties target = (org.apache.camel.main.TracerConfigurationProperties) obj; + switch (ignoreCase ? name.toLowerCase() : name) { + case "backlogsize": + case "BacklogSize": target.setBacklogSize(property(camelContext, int.class, value)); return true; + case "bodyincludefiles": + case "BodyIncludeFiles": target.setBodyIncludeFiles(property(camelContext, boolean.class, value)); return true; + case "bodyincludestreams": + case "BodyIncludeStreams": target.setBodyIncludeStreams(property(camelContext, boolean.class, value)); return true; + case "bodymaxchars": + case "BodyMaxChars": target.setBodyMaxChars(property(camelContext, int.class, value)); return true; + case "enabled": + case "Enabled": target.setEnabled(property(camelContext, boolean.class, value)); return true; + case "includeexception": + case "IncludeException": target.setIncludeException(property(camelContext, boolean.class, value)); return true; + case "includeexchangeproperties": + case "IncludeExchangeProperties": target.setIncludeExchangeProperties(property(camelContext, boolean.class, value)); return true; + case "includeexchangevariables": + case "IncludeExchangeVariables": target.setIncludeExchangeVariables(property(camelContext, boolean.class, value)); return true; + case "removeondump": + case "RemoveOnDump": target.setRemoveOnDump(property(camelContext, boolean.class, value)); return true; + case "standby": + case "Standby": target.setStandby(property(camelContext, boolean.class, value)); return true; + case "tracefilter": + case "TraceFilter": target.setTraceFilter(property(camelContext, java.lang.String.class, value)); return true; + case "tracepattern": + case "TracePattern": target.setTracePattern(property(camelContext, java.lang.String.class, value)); return true; + case "tracerests": + case "TraceRests": target.setTraceRests(property(camelContext, boolean.class, value)); return true; + case "tracetemplates": + case "TraceTemplates": target.setTraceTemplates(property(camelContext, boolean.class, value)); return true; + default: return false; + } + } + + @Override + public Class<?> getOptionType(String name, boolean ignoreCase) { + switch (ignoreCase ? name.toLowerCase() : name) { + case "backlogsize": + case "BacklogSize": return int.class; + case "bodyincludefiles": + case "BodyIncludeFiles": return boolean.class; + case "bodyincludestreams": + case "BodyIncludeStreams": return boolean.class; + case "bodymaxchars": + case "BodyMaxChars": return int.class; + case "enabled": + case "Enabled": return boolean.class; + case "includeexception": + case "IncludeException": return boolean.class; + case "includeexchangeproperties": + case "IncludeExchangeProperties": return boolean.class; + case "includeexchangevariables": + case "IncludeExchangeVariables": return boolean.class; + case "removeondump": + case "RemoveOnDump": return boolean.class; + case "standby": + case "Standby": return boolean.class; + case "tracefilter": + case "TraceFilter": return java.lang.String.class; + case "tracepattern": + case "TracePattern": return java.lang.String.class; + case "tracerests": + case "TraceRests": return boolean.class; + case "tracetemplates": + case "TraceTemplates": return boolean.class; + default: return null; + } + } + + @Override + 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 "backlogsize": + case "BacklogSize": return target.getBacklogSize(); + case "bodyincludefiles": + case "BodyIncludeFiles": return target.isBodyIncludeFiles(); + case "bodyincludestreams": + case "BodyIncludeStreams": return target.isBodyIncludeStreams(); + case "bodymaxchars": + case "BodyMaxChars": return target.getBodyMaxChars(); + case "enabled": + case "Enabled": return target.isEnabled(); + case "includeexception": + case "IncludeException": return target.isIncludeException(); + case "includeexchangeproperties": + case "IncludeExchangeProperties": return target.isIncludeExchangeProperties(); + case "includeexchangevariables": + case "IncludeExchangeVariables": return target.isIncludeExchangeVariables(); + case "removeondump": + case "RemoveOnDump": return target.isRemoveOnDump(); + case "standby": + case "Standby": return target.isStandby(); + case "tracefilter": + case "TraceFilter": return target.getTraceFilter(); + case "tracepattern": + case "TracePattern": return target.getTracePattern(); + case "tracerests": + case "TraceRests": return target.isTraceRests(); + case "tracetemplates": + case "TraceTemplates": return target.isTraceTemplates(); + 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 387d0a54077..1f763aafe27 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 @@ -4,6 +4,7 @@ { "name": "camel.routecontroller", "description": "Camel Route Controller configurations", "sourceType": "org.apache.camel.main.RouteControllerConfigurationProperties" }, { "name": "camel.server", "description": "Camel Embedded HTTP Server (only for standalone; not Spring Boot or Quarkus) configurations", "sourceType": "org.apache.camel.main.HttpServerConfigurationProperties" }, { "name": "camel.debug", "description": "Camel Debugger configurations", "sourceType": "org.apache.camel.main.DebuggerConfigurationProperties" }, + { "name": "camel.trace", "description": "Camel Tracer configurations", "sourceType": "org.apache.camel.main.TracerConfigurationProperties" }, { "name": "camel.ssl", "description": "Camel SSL configurations", "sourceType": "org.apache.camel.main.SSLConfigurationProperties" }, { "name": "camel.threadpool", "description": "Camel Thread Pool configurations", "sourceType": "org.apache.camel.main.ThreadPoolConfigurationProperties" }, { "name": "camel.health", "description": "Camel Health Check configurations", "sourceType": "org.apache.camel.main.HealthConfigurationProperties" }, @@ -26,9 +27,6 @@ { "name": "camel.main.autoConfigurationSystemPropertiesEnabled", "description": "Whether auto configuration should include JVM system properties as well. When enabled this allows to overrule any configuration using a JVM system property. For example to set a shutdown timeout of 5 seconds: -D camel.main.shutdown-timeout=5. Note that JVM system properties take precedence over OS environment variables. This option is default enabled.", "sourceType": "org.apache.camel.main.MainConfigurat [...] { "name": "camel.main.autoStartup", "description": "Sets whether the object should automatically start when Camel starts. Important: Currently only routes can be disabled, as CamelContext's are always started. Note: When setting auto startup false on CamelContext then that takes precedence and no routes are started. You would need to start CamelContext explicit using the org.apache.camel.CamelContext.start() method, to start the context, and then you would need to start the routes ma [...] { "name": "camel.main.autowiredEnabled", "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc. Default is true.", "sourceType": "org.apache.camel.main.DefaultConfiguration [...] - { "name": "camel.main.backlogTracing", "description": "Sets whether backlog tracing is enabled or not. Default is false.", "sourceType": "org.apache.camel.main.DefaultConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" }, - { "name": "camel.main.backlogTracingStandby", "description": "Whether to set backlog tracing on standby. If on standby then the backlog tracer is installed and made available. Then the backlog tracer can be enabled later at runtime via JMX or via Java API. Default is false.", "sourceType": "org.apache.camel.main.DefaultConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" }, - { "name": "camel.main.backlogTracingTemplates", "description": "Whether backlog tracing should trace inner details from route templates (or kamelets). Turning this on increases the verbosity of tracing by including events from internal routes in the templates or kamelets. Default is false.", "sourceType": "org.apache.camel.main.DefaultConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" }, { "name": "camel.main.basePackageScan", "description": "Package name to use as base (offset) for classpath scanning of RouteBuilder , org.apache.camel.TypeConverter , CamelConfiguration classes, and also classes annotated with org.apache.camel.Converter , or org.apache.camel.BindToRegistry . If you are using Spring Boot then it is instead recommended to use Spring Boots component scanning and annotate your route builder classes with Component. In other words only use this for Camel M [...] { "name": "camel.main.basePackageScanEnabled", "description": "Whether base package scan is enabled.", "sourceType": "org.apache.camel.main.MainConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": true }, { "name": "camel.main.beanIntrospectionExtendedStatistics", "description": "Sets whether bean introspection uses extended statistics. The default is false.", "sourceType": "org.apache.camel.main.DefaultConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" }, @@ -276,6 +274,20 @@ { "name": "camel.threadpool.poolSize", "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" }, { "name": "camel.threadpool.rejectedPolicy", "description": "Sets the default handler for tasks which cannot be executed by the thread pool.", "sourceType": "org.apache.camel.main.ThreadPoolConfigurationProperties", "type": "object", "javaType": "org.apache.camel.util.concurrent.ThreadPoolRejectedPolicy", "enum": [ "Abort", "CallerRuns", "DiscardOldest", "Discard" ] }, { "name": "camel.threadpool.timeUnit", "description": "Sets the default time unit used for keep alive time", "sourceType": "org.apache.camel.main.ThreadPoolConfigurationProperties", "type": "object", "javaType": "java.util.concurrent.TimeUnit" }, + { "name": "camel.trace.backlogSize", "description": "Defines how many of the last messages to keep in the tracer.", "sourceType": "org.apache.camel.main.TracerConfigurationProperties", "type": "integer", "javaType": "int", "defaultValue": 1000 }, + { "name": "camel.trace.bodyIncludeFiles", "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 }, + { "name": "camel.trace.bodyIncludeStreams", "description": "Whether to include the message body of stream based messages. If enabled then beware the stream may not be re-readable later. See more about Stream Caching.", "sourceType": "org.apache.camel.main.TracerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" }, + { "name": "camel.trace.bodyMaxChars", "description": "To limit the message body to a maximum size in the traced message. Use 0 or negative value to use unlimited size.", "sourceType": "org.apache.camel.main.TracerConfigurationProperties", "type": "integer", "javaType": "int", "defaultValue": 131072 }, + { "name": "camel.trace.enabled", "description": "Enables tracer in your Camel application.", "sourceType": "org.apache.camel.main.TracerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" }, + { "name": "camel.trace.includeException", "description": "Trace messages to include exception if the message failed", "sourceType": "org.apache.camel.main.TracerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": true }, + { "name": "camel.trace.includeExchangeProperties", "description": "Whether to include the exchange properties in the traced message", "sourceType": "org.apache.camel.main.TracerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": true }, + { "name": "camel.trace.includeExchangeVariables", "description": "Whether to include the exchange variables in the traced message", "sourceType": "org.apache.camel.main.TracerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": true }, + { "name": "camel.trace.removeOnDump", "description": "Whether all traced messages should be removed when the tracer is dumping. By default, the messages are removed, which means that dumping will not contain previous dumped messages.", "sourceType": "org.apache.camel.main.TracerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": true }, + { "name": "camel.trace.standby", "description": "To set the tracer in standby mode, where the tracer will be installed by not automatic enabled. The tracer can then later be enabled explicit from Java, JMX or tooling.", "sourceType": "org.apache.camel.main.TracerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" }, + { "name": "camel.trace.traceFilter", "description": "Filter for tracing messages", "sourceType": "org.apache.camel.main.TracerConfigurationProperties", "type": "string", "javaType": "java.lang.String" }, + { "name": "camel.trace.tracePattern", "description": "Filter for tracing by route or node id", "sourceType": "org.apache.camel.main.TracerConfigurationProperties", "type": "string", "javaType": "java.lang.String" }, + { "name": "camel.trace.traceRests", "description": "Whether to trace routes that is created from Rest DSL.", "sourceType": "org.apache.camel.main.TracerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" }, + { "name": "camel.trace.traceTemplates", "description": "Whether to trace routes that is created from route templates or kamelets.", "sourceType": "org.apache.camel.main.TracerConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" }, { "name": "camel.vault.aws.accessKey", "description": "The AWS access key", "sourceType": "org.apache.camel.vault.AwsVaultConfiguration", "type": "string", "javaType": "java.lang.String" }, { "name": "camel.vault.aws.defaultCredentialsProvider", "description": "Define if we want to use the AWS Default Credentials Provider or not", "sourceType": "org.apache.camel.vault.AwsVaultConfiguration", "type": "boolean", "javaType": "boolean", "defaultValue": "false" }, { "name": "camel.vault.aws.profileCredentialsProvider", "description": "Define if we want to use the AWS Profile Credentials Provider or not", "sourceType": "org.apache.camel.vault.AwsVaultConfiguration", "type": "boolean", "javaType": "boolean", "defaultValue": "false" }, diff --git a/core/camel-main/src/generated/resources/META-INF/services/org/apache/camel/configurer/org.apache.camel.main.TracerConfigurationProperties b/core/camel-main/src/generated/resources/META-INF/services/org/apache/camel/configurer/org.apache.camel.main.TracerConfigurationProperties new file mode 100644 index 00000000000..583a77567ee --- /dev/null +++ b/core/camel-main/src/generated/resources/META-INF/services/org/apache/camel/configurer/org.apache.camel.main.TracerConfigurationProperties @@ -0,0 +1,2 @@ +# Generated by camel build tools - do NOT edit this file! +class=org.apache.camel.main.TracerConfigurationPropertiesConfigurer diff --git a/core/camel-main/src/main/docs/main.adoc b/core/camel-main/src/main/docs/main.adoc index a6326e2fdb7..3496e7c35c6 100644 --- a/core/camel-main/src/main/docs/main.adoc +++ b/core/camel-main/src/main/docs/main.adoc @@ -19,7 +19,7 @@ The following tables lists all the options: // main options: START === Camel Main configurations -The camel.main supports 119 options, which are listed below. +The camel.main supports 116 options, which are listed below. [width="100%",cols="2,5,^1,2",options="header"] |=== @@ -32,9 +32,6 @@ The camel.main supports 119 options, which are listed below. | *camel.main.autoConfiguration{zwsp}SystemPropertiesEnabled* | Whether auto configuration should include JVM system properties as well. When enabled this allows to overrule any configuration using a JVM system property. For example to set a shutdown timeout of 5 seconds: -D camel.main.shutdown-timeout=5. Note that JVM system properties take precedence over OS environment variables. This option is default enabled. | true | boolean | *camel.main.autoStartup* | Sets whether the object should automatically start when Camel starts. Important: Currently only routes can be disabled, as CamelContext's are always started. Note: When setting auto startup false on CamelContext then that takes precedence and no routes are started. You would need to start CamelContext explicit using the org.apache.camel.CamelContext.start() method, to start the context, and then you would need to start the routes manually using CamelContext.g [...] | *camel.main.autowiredEnabled* | Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc. Default is true. | true | boolean -| *camel.main.backlogTracing* | Sets whether backlog tracing is enabled or not. Default is false. | false | boolean -| *camel.main.backlogTracing{zwsp}Standby* | Whether to set backlog tracing on standby. If on standby then the backlog tracer is installed and made available. Then the backlog tracer can be enabled later at runtime via JMX or via Java API. Default is false. | false | boolean -| *camel.main.backlogTracing{zwsp}Templates* | Whether backlog tracing should trace inner details from route templates (or kamelets). Turning this on increases the verbosity of tracing by including events from internal routes in the templates or kamelets. Default is false. | false | boolean | *camel.main.basePackageScan* | Package name to use as base (offset) for classpath scanning of RouteBuilder , org.apache.camel.TypeConverter , CamelConfiguration classes, and also classes annotated with org.apache.camel.Converter , or org.apache.camel.BindToRegistry . If you are using Spring Boot then it is instead recommended to use Spring Boots component scanning and annotate your route builder classes with Component. In other words only use this for Camel Main in standalone mode. | [...] | *camel.main.basePackageScan{zwsp}Enabled* | Whether base package scan is enabled. | true | boolean | *camel.main.beanIntrospection{zwsp}ExtendedStatistics* | Sets whether bean introspection uses extended statistics. The default is false. | false | boolean @@ -211,6 +208,29 @@ The camel.debug supports 13 options, which are listed below. |=== +=== Camel Tracer configurations +The camel.trace supports 14 options, which are listed below. + +[width="100%",cols="2,5,^1,2",options="header"] +|=== +| Name | Description | Default | Type +| *camel.trace.backlogSize* | Defines how many of the last messages to keep in the tracer. | 1000 | 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 +| *camel.trace.bodyIncludeStreams* | Whether to include the message body of stream based messages. If enabled then beware the stream may not be re-readable later. See more about Stream Caching. | false | boolean +| *camel.trace.bodyMaxChars* | To limit the message body to a maximum size in the traced message. Use 0 or negative value to use unlimited size. | 131072 | int +| *camel.trace.enabled* | Enables tracer in your Camel application. | false | boolean +| *camel.trace.includeException* | Trace messages to include exception if the message failed | true | boolean +| *camel.trace.includeExchange{zwsp}Properties* | Whether to include the exchange properties in the traced message | true | boolean +| *camel.trace.includeExchange{zwsp}Variables* | Whether to include the exchange variables in the traced message | true | boolean +| *camel.trace.removeOnDump* | Whether all traced messages should be removed when the tracer is dumping. By default, the messages are removed, which means that dumping will not contain previous dumped messages. | true | boolean +| *camel.trace.standby* | To set the tracer in standby mode, where the tracer will be installed by not automatic enabled. The tracer can then later be enabled explicit from Java, JMX or tooling. | false | boolean +| *camel.trace.traceFilter* | Filter for tracing messages | | String +| *camel.trace.tracePattern* | Filter for tracing by route or node id | | String +| *camel.trace.traceRests* | Whether to trace routes that is created from Rest DSL. | false | boolean +| *camel.trace.traceTemplates* | Whether to trace routes that is created from route templates or kamelets. | false | boolean +|=== + + === Camel SSL configurations The camel.ssl supports 6 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 e01c21dc446..05ce66c0651 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.impl.engine.DefaultRoutesLoader; import org.apache.camel.saga.CamelSagaService; import org.apache.camel.spi.AutowiredLifecycleStrategy; import org.apache.camel.spi.BacklogDebugger; +import org.apache.camel.spi.BacklogTracer; import org.apache.camel.spi.CamelBeanPostProcessor; import org.apache.camel.spi.CamelEvent; import org.apache.camel.spi.CamelMetricsService; @@ -991,6 +992,7 @@ public abstract class BaseMainSupport extends BaseService { OrderedLocationProperties httpServerProperties = new OrderedLocationProperties(); OrderedLocationProperties sslProperties = new OrderedLocationProperties(); OrderedLocationProperties debuggerProperties = new OrderedLocationProperties(); + OrderedLocationProperties tracerProperties = new OrderedLocationProperties(); OrderedLocationProperties routeControllerProperties = new OrderedLocationProperties(); for (String key : prop.stringPropertyNames()) { String loc = prop.getLocation(key); @@ -1102,6 +1104,12 @@ public abstract class BaseMainSupport extends BaseService { String option = key.substring(12); validateOptionAndValue(key, option, value); debuggerProperties.put(loc, optionKey(option), value); + } else if (key.startsWith("camel.trace.")) { + // grab the value + String value = prop.getProperty(key); + String option = key.substring(12); + validateOptionAndValue(key, option, value); + tracerProperties.put(loc, optionKey(option), value); } else if (key.startsWith("camel.routeController.")) { // grab the value String value = prop.getProperty(key); @@ -1206,6 +1214,12 @@ public abstract class BaseMainSupport extends BaseService { mainConfigurationProperties.isAutoConfigurationFailFast(), autoConfiguredProperties); } + if (!tracerProperties.isEmpty() || mainConfigurationProperties.hasTracerConfiguration()) { + LOG.debug("Auto-configuring Tracer from loaded properties: {}", tracerProperties.size()); + setTracerProperties(camelContext, tracerProperties, + mainConfigurationProperties.isAutoConfigurationFailFast(), + autoConfiguredProperties); + } if (!routeControllerProperties.isEmpty() || mainConfigurationProperties.hasRouteControllerConfiguration()) { LOG.debug("Auto-configuring Route Controller from loaded properties: {}", routeControllerProperties.size()); setRouteControllerProperties(camelContext, routeControllerProperties, @@ -1674,6 +1688,47 @@ public abstract class BaseMainSupport extends BaseService { camelContext.addService(debugger); } + private void setTracerProperties( + CamelContext camelContext, OrderedLocationProperties properties, + boolean failIfNotSet, OrderedLocationProperties autoConfiguredProperties) + throws Exception { + + TracerConfigurationProperties config = mainConfigurationProperties.tracerConfig(); + setPropertiesOnTarget(camelContext, config, properties, "camel.tracer.", + failIfNotSet, true, autoConfiguredProperties); + + if (!config.isEnabled() && !config.isStandby()) { + return; + } + + // must enable source location so tracer tooling knows to map breakpoints to source code + camelContext.setSourceLocationEnabled(true); + + // enable tracer on camel + camelContext.setBacklogTracing(config.isEnabled()); + camelContext.setBacklogTracingStandby(config.isStandby()); + camelContext.setBacklogTracingTemplates(config.isTraceTemplates()); + + BacklogTracer tracer = org.apache.camel.impl.debugger.BacklogTracer.createTracer(camelContext); + tracer.setEnabled(config.isEnabled()); + tracer.setStandby(config.isStandby()); + tracer.setBacklogSize(config.getBacklogSize()); + tracer.setRemoveOnDump(config.isRemoveOnDump()); + tracer.setBodyMaxChars(config.getBodyMaxChars()); + tracer.setBodyIncludeStreams(config.isBodyIncludeStreams()); + tracer.setBodyIncludeFiles(config.isBodyIncludeFiles()); + tracer.setIncludeExchangeProperties(config.isIncludeExchangeProperties()); + tracer.setIncludeExchangeVariables(config.isIncludeExchangeVariables()); + tracer.setIncludeException(config.isIncludeException()); + tracer.setTraceRests(config.isTraceRests()); + tracer.setTraceTemplates(config.isTraceTemplates()); + tracer.setTracePattern(config.getTracePattern()); + tracer.setTraceFilter(config.getTraceFilter()); + + camelContext.getCamelContextExtension().addContextPlugin(BacklogTracer.class, tracer); + camelContext.addService(tracer); + } + private void setRouteControllerProperties( CamelContext camelContext, OrderedLocationProperties properties, boolean failIfNotSet, OrderedLocationProperties autoConfiguredProperties) diff --git a/core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationConfigurer.java b/core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationConfigurer.java index 22674dad7f2..c727f84f64b 100644 --- a/core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationConfigurer.java +++ b/core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationConfigurer.java @@ -325,9 +325,6 @@ public final class DefaultConfigurationConfigurer { camelContext.setSourceLocationEnabled(true); } - camelContext.setBacklogTracing(config.isBacklogTracing()); - camelContext.setBacklogTracingStandby(config.isBacklogTracingStandby()); - camelContext.setBacklogTracingTemplates(config.isBacklogTracingTemplates()); camelContext.setTracing(config.isTracing()); camelContext.setTracingStandby(config.isTracingStandby()); camelContext.setTracingPattern(config.getTracingPattern()); diff --git a/core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationProperties.java b/core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationProperties.java index 4796e7cfd61..44137d6801d 100644 --- a/core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationProperties.java +++ b/core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationProperties.java @@ -71,9 +71,6 @@ public abstract class DefaultConfigurationProperties<T> { private int streamCachingBufferSize; private boolean streamCachingRemoveSpoolDirectoryWhenStopping = true; private boolean streamCachingStatisticsEnabled; - private boolean backlogTracing; - private boolean backlogTracingStandby; - private boolean backlogTracingTemplates; private boolean typeConverterStatisticsEnabled; private boolean tracing; private boolean tracingStandby; @@ -689,47 +686,6 @@ public abstract class DefaultConfigurationProperties<T> { tracingLoggingFormat = format; } - public boolean isBacklogTracing() { - return backlogTracing; - } - - /** - * Sets whether backlog tracing is enabled or not. - * - * Default is false. - */ - public void setBacklogTracing(boolean backlogTracing) { - this.backlogTracing = backlogTracing; - } - - public boolean isBacklogTracingStandby() { - return backlogTracingStandby; - } - - /** - * Whether to set backlog tracing on standby. If on standby then the backlog tracer is installed and made available. - * Then the backlog tracer can be enabled later at runtime via JMX or via Java API. - * - * Default is false. - */ - public void setBacklogTracingStandby(boolean backlogTracingStandby) { - this.backlogTracingStandby = backlogTracingStandby; - } - - public boolean isBacklogTracingTemplates() { - return backlogTracingTemplates; - } - - /** - * Whether backlog tracing should trace inner details from route templates (or kamelets). Turning this on increases - * the verbosity of tracing by including events from internal routes in the templates or kamelets. - * - * Default is false. - */ - public void setBacklogTracingTemplates(boolean backlogTracingTemplates) { - this.backlogTracingTemplates = backlogTracingTemplates; - } - public boolean isMessageHistory() { return messageHistory; } @@ -2005,38 +1961,6 @@ public abstract class DefaultConfigurationProperties<T> { return (T) this; } - /** - * Sets whether backlog tracing is enabled or not. - * - * Default is false. - */ - public T withBacklogTracing(boolean backlogTracing) { - this.backlogTracing = backlogTracing; - return (T) this; - } - - /** - * Whether to set backlog tracing on standby. If on standby then the backlog tracer is installed and made available. - * Then the backlog tracer can be enabled later at runtime via JMX or via Java API. - * - * Default is false. - */ - public T withBacklogTracingStandby(boolean backlogTracingStandby) { - this.backlogTracingStandby = backlogTracingStandby; - return (T) this; - } - - /** - * Whether backlog tracing should trace inner details from route templates (or kamelets). Turning this on increases - * the verbosity of tracing by including events from internal routes in the templates or kamelets. - * - * Default is false. - */ - public T withBacklogTracingTemplates(boolean backlogTracingTemplates) { - this.backlogTracingTemplates = backlogTracingTemplates; - return (T) this; - } - /** * Sets whether message history is enabled or not. * 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 e3d8512ef36..f64a9d5c78a 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 @@ -63,6 +63,7 @@ public class MainConfigurationProperties extends DefaultConfigurationProperties< private HttpServerConfigurationProperties httpServerConfigurationProperties; private SSLConfigurationProperties sslConfigurationProperties; private DebuggerConfigurationProperties debuggerConfigurationProperties; + private TracerConfigurationProperties tracerConfigurationProperties; private RouteControllerConfigurationProperties routeControllerConfigurationProperties; @Override @@ -115,6 +116,10 @@ public class MainConfigurationProperties extends DefaultConfigurationProperties< debuggerConfigurationProperties.close(); debuggerConfigurationProperties = null; } + if (tracerConfigurationProperties != null) { + tracerConfigurationProperties.close(); + tracerConfigurationProperties = null; + } if (routeControllerConfigurationProperties != null) { routeControllerConfigurationProperties.close(); routeControllerConfigurationProperties = null; @@ -253,6 +258,24 @@ public class MainConfigurationProperties extends DefaultConfigurationProperties< return debuggerConfigurationProperties != null; } + /** + * To configure Tracer. + */ + public TracerConfigurationProperties tracerConfig() { + if (tracerConfigurationProperties == null) { + tracerConfigurationProperties = new TracerConfigurationProperties(this); + } + + return tracerConfigurationProperties; + } + + /** + * Whether there has been any Tracer configuration specified. + */ + public boolean hasTracerConfiguration() { + return tracerConfigurationProperties != null; + } + /** * To configure Route Controller. */ 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 new file mode 100644 index 00000000000..5e18657c6a4 --- /dev/null +++ b/core/camel-main/src/main/java/org/apache/camel/main/TracerConfigurationProperties.java @@ -0,0 +1,347 @@ +/* + * 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; + +/** + * Tracer configuration. + */ +@Configurer(bootstrap = true) +public class TracerConfigurationProperties implements BootstrapCloseable { + + private MainConfigurationProperties parent; + + @Metadata + private boolean enabled; + @Metadata + private boolean standby; + @Metadata(label = "advanced", defaultValue = "1000") + private int backlogSize = 1000; + @Metadata(label = "advanced", defaultValue = "true") + private boolean removeOnDump = true; + @Metadata(label = "advanced", defaultValue = "131072") + private int bodyMaxChars = 128 * 1024; + @Metadata + private boolean bodyIncludeStreams; + @Metadata(defaultValue = "true") + private boolean bodyIncludeFiles = true; + @Metadata(defaultValue = "true") + private boolean includeExchangeProperties = true; + @Metadata(defaultValue = "true") + private boolean includeExchangeVariables = true; + @Metadata(defaultValue = "true") + private boolean includeException = true; + @Metadata(label = "advanced") + private boolean traceRests; + @Metadata(label = "advanced") + private boolean traceTemplates; + @Metadata + private String tracePattern; + @Metadata + private String traceFilter; + + public TracerConfigurationProperties(MainConfigurationProperties parent) { + this.parent = parent; + } + + public MainConfigurationProperties end() { + return parent; + } + + @Override + public void close() { + parent = null; + } + + public boolean isEnabled() { + return enabled; + } + + /** + * Enables tracer in your Camel application. + */ + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + + public boolean isStandby() { + return standby; + } + + /** + * To set the tracer in standby mode, where the tracer will be installed by not automatic enabled. The tracer can + * then later be enabled explicit from Java, JMX or tooling. + */ + public void setStandby(boolean standby) { + this.standby = standby; + } + + public int getBacklogSize() { + return backlogSize; + } + + /** + * Defines how many of the last messages to keep in the tracer. + */ + public void setBacklogSize(int backlogSize) { + this.backlogSize = backlogSize; + } + + public boolean isRemoveOnDump() { + return removeOnDump; + } + + /** + * Whether all traced messages should be removed when the tracer is dumping. By default, the messages are removed, + * which means that dumping will not contain previous dumped messages. + */ + public void setRemoveOnDump(boolean removeOnDump) { + this.removeOnDump = removeOnDump; + } + + public int getBodyMaxChars() { + return bodyMaxChars; + } + + /** + * To limit the message body to a maximum size in the traced message. Use 0 or negative value to use unlimited size. + */ + public void setBodyMaxChars(int bodyMaxChars) { + this.bodyMaxChars = bodyMaxChars; + } + + public boolean isBodyIncludeStreams() { + return bodyIncludeStreams; + } + + /** + * Whether to include the message body of stream based messages. If enabled then beware the stream may not be + * re-readable later. See more about Stream Caching. + */ + public void setBodyIncludeStreams(boolean bodyIncludeStreams) { + this.bodyIncludeStreams = bodyIncludeStreams; + } + + public boolean isBodyIncludeFiles() { + return 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. + */ + public void setBodyIncludeFiles(boolean bodyIncludeFiles) { + this.bodyIncludeFiles = bodyIncludeFiles; + } + + public boolean isIncludeExchangeProperties() { + return includeExchangeProperties; + } + + /** + * Whether to include the exchange properties in the traced message + */ + public void setIncludeExchangeProperties(boolean includeExchangeProperties) { + this.includeExchangeProperties = includeExchangeProperties; + } + + public boolean isIncludeExchangeVariables() { + return includeExchangeVariables; + } + + /** + * Whether to include the exchange variables in the traced message + */ + public void setIncludeExchangeVariables(boolean includeExchangeVariables) { + this.includeExchangeVariables = includeExchangeVariables; + } + + public boolean isIncludeException() { + return includeException; + } + + /** + * Trace messages to include exception if the message failed + */ + public void setIncludeException(boolean includeException) { + this.includeException = includeException; + } + + public boolean isTraceRests() { + return traceRests; + } + + /** + * Whether to trace routes that is created from Rest DSL. + */ + public void setTraceRests(boolean traceRests) { + this.traceRests = traceRests; + } + + public boolean isTraceTemplates() { + return traceTemplates; + } + + /** + * Whether to trace routes that is created from route templates or kamelets. + */ + public void setTraceTemplates(boolean traceTemplates) { + this.traceTemplates = traceTemplates; + } + + public String getTracePattern() { + return tracePattern; + } + + /** + * Filter for tracing by route or node id + */ + public void setTracePattern(String tracePattern) { + this.tracePattern = tracePattern; + } + + public String getTraceFilter() { + return traceFilter; + } + + /** + * Filter for tracing messages + */ + public void setTraceFilter(String traceFilter) { + this.traceFilter = traceFilter; + } + + /** + * Enables tracer in your Camel application. + */ + public TracerConfigurationProperties withEnabled(boolean enabled) { + this.enabled = enabled; + return this; + } + + /** + * To set the tracer in standby mode, where the tracer will be installed by not automatic enabled. The tracer can + * then later be enabled explicit from Java, JMX or tooling. + */ + public TracerConfigurationProperties withStandby(boolean standby) { + this.standby = standby; + return this; + } + + /** + * Defines how many of the last messages to keep in the tracer. + */ + public TracerConfigurationProperties withBacklogSize(int backlogSize) { + this.backlogSize = backlogSize; + return this; + } + + /** + * Whether all traced messages should be removed when the tracer is dumping. By default, the messages are removed, + * which means that dumping will not contain previous dumped messages. + */ + public TracerConfigurationProperties withRemoveOnDump(boolean removeOnDump) { + this.removeOnDump = removeOnDump; + return this; + } + + /** + * Whether to trace routes that is created from Rest DSL. + */ + public TracerConfigurationProperties withTraceRests(boolean traceRests) { + this.traceRests = traceRests; + return this; + } + + /** + * Whether to trace routes that is created from route templates or kamelets. + */ + public TracerConfigurationProperties withTraceTemplates(boolean traceTemplates) { + this.traceTemplates = traceTemplates; + return this; + } + + /** + * To limit the message body to a maximum size in the traced message. Use 0 or negative value to use unlimited size. + */ + public TracerConfigurationProperties withBodyMaxChars(int bodyMaxChars) { + this.bodyMaxChars = bodyMaxChars; + return this; + } + + /** + * Whether to include the message body of stream based messages. If enabled then beware the stream may not be + * re-readable later. See more about Stream Caching. + */ + public TracerConfigurationProperties withBodyIncludeStreams(boolean bodyIncludeStreams) { + this.bodyIncludeStreams = bodyIncludeStreams; + return this; + } + + /** + * Whether to include the message body of file based messages. The overhead is that the file content has to be read + * from the file. + */ + public TracerConfigurationProperties withBodyIncludeFiles(boolean bodyIncludeFiles) { + this.bodyIncludeFiles = bodyIncludeFiles; + return this; + } + + /** + * Whether to include the exchange properties in the traced message + */ + public TracerConfigurationProperties withIncludeExchangeProperties(boolean includeExchangeProperties) { + this.includeExchangeProperties = includeExchangeProperties; + return this; + } + + /** + * Whether to include the exchange variables in the traced message + */ + public TracerConfigurationProperties withIncludeExchangeVariables(boolean includeExchangeVariables) { + this.includeExchangeVariables = includeExchangeVariables; + return this; + } + + /** + * Trace messages to include exception if the message failed + */ + public TracerConfigurationProperties withIncludeException(boolean includeException) { + this.includeException = includeException; + return this; + } + + /** + * Filter for tracing by route or node id + */ + public TracerConfigurationProperties withTracePattern(String tracePattern) { + this.tracePattern = tracePattern; + return this; + } + + /** + * Filter for tracing messages + */ + public TracerConfigurationProperties withTraceFilter(String traceFilter) { + this.traceFilter = traceFilter; + return this; + } + +} diff --git a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_5.adoc b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_5.adoc index 955a601da16..bdfe969ff7d 100644 --- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_5.adoc +++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_5.adoc @@ -102,6 +102,13 @@ After: String uri = exchange.getProperty(Exchange.INTERCEPTED_ENDPOINT, String.class); ---- +=== camel-main + +The options `camel.main.backlogTracing`, `"camel.main.backlogTracingStandby`, and `camel.main.backlogTracingTemplates` has been +moved into a new group `camel.debug` with more options to configure the backlog tracer. + +To enable backlog tracing you should now set `camel.trace.enabled=true` instead of `camel.main.backlogTracing=true`. + === camel-kamelet Routes created by Kamelets are no longer registered as JMX MBeans to avoid cluttering up with unwanted MBeans, as a Kamelet diff --git a/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/KameletMain.java b/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/KameletMain.java index 8035e6cabd8..5b51d0d6f78 100644 --- a/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/KameletMain.java +++ b/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/KameletMain.java @@ -473,7 +473,7 @@ public class KameletMain extends MainCommandLineSupport { boolean tracing = "true".equals(getInitialProperties().get("camel.jbang.backlogTracing")); if (tracing) { - configure().withBacklogTracing(true); + configure().tracerConfig().withEnabled(true); } boolean infoConsole = "true".equals(getInitialProperties().get("camel.jbang.info")); if (infoConsole) { 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 5c208a906b8..715af3e6ae8 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 @@ -219,6 +219,8 @@ public class PrepareCamelMainMojo extends AbstractGeneratorMojo { prefix = "camel.ssl."; } else if (file.getName().contains("DebuggerConfigurationProperties")) { prefix = "camel.debug."; + } else if (file.getName().contains("TracerConfigurationProperties")) { + prefix = "camel.trace."; } else if (file.getName().contains("RouteControllerConfigurationProperties")) { prefix = "camel.routecontroller."; } else { @@ -299,6 +301,10 @@ public class PrepareCamelMainMojo extends AbstractGeneratorMojo { .add(new MainGroupModel( "camel.debug", "Camel Debugger configurations", "org.apache.camel.main.DebuggerConfigurationProperties")); + model.getGroups() + .add(new MainGroupModel( + "camel.trace", "Camel Tracer configurations", + "org.apache.camel.main.TracerConfigurationProperties")); model.getGroups() .add(new MainGroupModel( "camel.ssl", "Camel SSL configurations",