davsclaus commented on code in PR #19297:
URL: https://github.com/apache/camel/pull/19297#discussion_r2387156875
##########
core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java:
##########
@@ -2741,6 +2781,20 @@ private static CamelMetricsService
resolveMicrometerService(CamelContext camelCo
return answer;
}
+ private static CamelMDCService resolveMDCService(CamelContext
camelContext) throws Exception {
+ CamelMDCService answer =
camelContext.hasService(CamelMDCService.class);
+ if (answer == null) {
+ answer =
camelContext.getRegistry().findSingleByType(CamelMDCService.class);
+ }
+ if (answer == null) {
+ answer =
camelContext.getCamelContextExtension().getBootstrapFactoryFinder()
+ .newInstance("mdc-service", CamelMDCService.class)
+ .orElseThrow(() -> new IllegalArgumentException(
+ "Cannot find OpenTelemetryTracer2 on classpath.
Add camel-opentelemetry2 to classpath."));
Review Comment:
Wrong name here
##########
core/camel-main/src/main/docs/main.adoc:
##########
@@ -562,6 +562,18 @@ The camel.telemetryDev supports 4 options, which are
listed below.
|===
+=== Camel MDC configurations
+The camel.mdc supports 3 options, which are listed below.
+
+[width="100%",cols="2,5,^1,2",options="header"]
+|===
+| Name | Description | Default | Type
+| *camel.mdc.customHeaders* | Provide the headers you would like to use in the
logging. Use value to include all available headers | | String
Review Comment:
Notice here how * is not in the doc (see lateR)
##########
core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java:
##########
@@ -1851,6 +1869,28 @@ private void setOtel2Properties(
}
}
+ private void setMdcProperties(
+ CamelContext camelContext, OrderedLocationProperties mdcProperties,
+ boolean failIfNotSet, OrderedLocationProperties
autoConfiguredProperties)
+ throws Exception {
+
+ String loc = mdcProperties.getLocation("enabled");
+ Object obj = mdcProperties.remove("enabled");
+ if (ObjectHelper.isNotEmpty(obj)) {
+ autoConfiguredProperties.put(loc, "camel.mdc.enabled",
obj.toString());
+ }
+ boolean enabled = obj != null ?
CamelContextHelper.parseBoolean(camelContext, obj.toString()) : true;
+ if (enabled) {
+ CamelMDCService mdc = resolveMDCService(camelContext);
+ setPropertiesOnTarget(camelContext, mdc, mdcProperties,
"camel.mdc.", failIfNotSet, true,
Review Comment:
The true value seems like its default enabled
##########
core/camel-main/src/main/java/org/apache/camel/main/MdcConfigurationProperties.java:
##########
@@ -0,0 +1,104 @@
+/*
+ * 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;
+
+/**
+ * Global configuration for MDC
+ */
+@Configurer(extended = true)
+public class MdcConfigurationProperties implements BootstrapCloseable {
+
+ private MainConfigurationProperties parent;
+
+ private boolean enabled;
+ private String customHeaders;
+ private String customProperties;
+
+ public MdcConfigurationProperties(MainConfigurationProperties parent) {
+ this.parent = parent;
+ }
+
+ public MainConfigurationProperties end() {
+ return parent;
+ }
+
+ @Override
+ public void close() {
+ parent = null;
+ }
+
+ public boolean isEnabled() {
+ return enabled;
+ }
+
+ /**
+ * To enable MDC service
+ */
+ public void setEnabled(boolean enabled) {
+ this.enabled = enabled;
+ }
+
+ public String getCustomHeaders() {
+ return customHeaders;
+ }
+
+ /**
+ * Provide the headers you would like to use in the logging. Use `*` value
to include all available headers
Review Comment:
The '*' is not in the doc so maybe try without the quotes
##########
core/camel-main/src/main/java/org/apache/camel/main/MdcConfigurationProperties.java:
##########
@@ -0,0 +1,104 @@
+/*
+ * 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;
+
+/**
+ * Global configuration for MDC
+ */
+@Configurer(extended = true)
+public class MdcConfigurationProperties implements BootstrapCloseable {
+
+ private MainConfigurationProperties parent;
+
+ private boolean enabled;
+ private String customHeaders;
+ private String customProperties;
+
+ public MdcConfigurationProperties(MainConfigurationProperties parent) {
+ this.parent = parent;
+ }
+
+ public MainConfigurationProperties end() {
+ return parent;
+ }
+
+ @Override
+ public void close() {
+ parent = null;
+ }
+
+ public boolean isEnabled() {
+ return enabled;
+ }
+
+ /**
+ * To enable MDC service
+ */
+ public void setEnabled(boolean enabled) {
+ this.enabled = enabled;
+ }
+
+ public String getCustomHeaders() {
+ return customHeaders;
+ }
+
+ /**
+ * Provide the headers you would like to use in the logging. Use `*` value
to include all available headers
+ */
+ public void setCustomHeaders(String customHeaders) {
+ this.customHeaders = customHeaders;
+ }
+
+ public String getCustomProperties() {
+ return customProperties;
+ }
+
+ /**
+ * Provide the properties you would like to use in the logging. Use `*`
value to include all available properties
Review Comment:
properties is ambitious, favour using exchange properties
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]