This is an automated email from the ASF dual-hosted git repository.

pcongiusti pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new c6ec694adea feat(components): deprecate tracing MDC
c6ec694adea is described below

commit c6ec694adeaa9e5a60514642f28488cf07615f5a
Author: Pasquale Congiusti <[email protected]>
AuthorDate: Thu Dec 12 12:42:37 2024 +0100

    feat(components): deprecate tracing MDC
    
    Favoring instead the instrumentation provided into each specific tracing 
framework.
    
    Closes CAMEL-21538
---
 components/camel-observation/src/main/docs/observation.adoc       | 4 +++-
 components/camel-opentelemetry/src/main/docs/opentelemetry.adoc   | 2 +-
 components/camel-tracing/src/main/docs/tracing.adoc               | 3 +++
 .../src/main/java/org/apache/camel/tracing/ActiveSpanManager.java | 4 ++++
 .../src/main/java/org/apache/camel/tracing/Tracer.java            | 8 ++++++++
 .../modules/ROOT/pages/camel-4x-upgrade-guide-4_10.adoc           | 6 +++++-
 docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide.adoc   | 1 -
 7 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/components/camel-observation/src/main/docs/observation.adoc 
b/components/camel-observation/src/main/docs/observation.adoc
index 16f613b5ff0..84370ce0487 100644
--- a/components/camel-observation/src/main/docs/observation.adoc
+++ b/components/camel-observation/src/main/docs/observation.adoc
@@ -86,4 +86,6 @@ include::spring-boot:partial$starter.adoc[]
 
 == MDC Logging
 
-When MDC Logging is enabled for the active Camel context the Trace ID and Span 
ID will be added and removed from the MDC for each route, the keys are 
`trace_id` and `span_id`, respectively.
+You can add [Micrometer Observability Mapped Diagnostic Context tracing 
information](https://docs.micrometer.io/tracing/reference/index.html) (ie, 
`traceId` and `spanId`) adding some instrumentation bridge to your application. 
You may add the `io.micrometer:micrometer-tracing-bridge-otel` dependency and 
you will be able to get those MDC information automatically.
+
+NOTE: mind that MDC variables `traceId` and `spanId` are different from other 
tracing implementations (eg, `camel-opentelemetry`) which use `trace_id` and 
`span_id`.
diff --git a/components/camel-opentelemetry/src/main/docs/opentelemetry.adoc 
b/components/camel-opentelemetry/src/main/docs/opentelemetry.adoc
index 44e0d3f5b9d..bd49b02b166 100644
--- a/components/camel-opentelemetry/src/main/docs/opentelemetry.adoc
+++ b/components/camel-opentelemetry/src/main/docs/opentelemetry.adoc
@@ -158,4 +158,4 @@ Multiple `SpanExporters` can be used at the same time.
 
 == MDC Logging
 
-When MDC Logging is enabled for the active Camel context the Trace ID and Span 
ID will be added and removed from the MDC for each route, the keys are 
`trace_id` and `span_id`, respectively.
+You can add Mapped Diagnostic Context tracing information (ie, `trace_id` and 
`span_id`) adding the specific [Opentelemetry Logger MDC auto 
instrumentation](https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/docs/logger-mdc-instrumentation.md).
 The configuration depends on the logging framework you're using.
diff --git a/components/camel-tracing/src/main/docs/tracing.adoc 
b/components/camel-tracing/src/main/docs/tracing.adoc
index 0e01a56fd98..a179c247a5a 100644
--- a/components/camel-tracing/src/main/docs/tracing.adoc
+++ b/components/camel-tracing/src/main/docs/tracing.adoc
@@ -16,3 +16,6 @@ This module is not intended to be used by end users. Instead, 
you should use one
 * xref:opentelemetry.adoc[`camel-opentelemetry`]
 * xref:observation.adoc[`camel-observation`]
 
+== MDC logging
+
+Mapped Diagnostic Context logging *trace_id* and *span_id* are included when 
you're setting the MDC configuration `camel.main.use-mdc-logging = true`. 
However this is a **deprecated** feature that may disappear in future version 
of the project. The feature can be enabled using the specific tracing/telemetry 
framework SDK. See more detail on the tracing component documentation page 
you're using.
\ No newline at end of file
diff --git 
a/components/camel-tracing/src/main/java/org/apache/camel/tracing/ActiveSpanManager.java
 
b/components/camel-tracing/src/main/java/org/apache/camel/tracing/ActiveSpanManager.java
index b86c27871ed..ffdcbb23b4b 100644
--- 
a/components/camel-tracing/src/main/java/org/apache/camel/tracing/ActiveSpanManager.java
+++ 
b/components/camel-tracing/src/main/java/org/apache/camel/tracing/ActiveSpanManager.java
@@ -27,7 +27,11 @@ import org.slf4j.MDC;
  */
 public final class ActiveSpanManager {
 
+    @Deprecated
+    // Use specific MDC instrumentation provided by your tracing/telemetry SDK 
instead
     public static final String MDC_TRACE_ID = "trace_id";
+    @Deprecated
+    // Use specific MDC instrumentation provided by your tracing/telemetry SDK 
instead
     public static final String MDC_SPAN_ID = "span_id";
     private static final Logger LOG = 
LoggerFactory.getLogger(ActiveSpanManager.class);
 
diff --git 
a/components/camel-tracing/src/main/java/org/apache/camel/tracing/Tracer.java 
b/components/camel-tracing/src/main/java/org/apache/camel/tracing/Tracer.java
index 496aea2eb90..5e656ae19d0 100644
--- 
a/components/camel-tracing/src/main/java/org/apache/camel/tracing/Tracer.java
+++ 
b/components/camel-tracing/src/main/java/org/apache/camel/tracing/Tracer.java
@@ -173,6 +173,14 @@ public abstract class Tracer extends ServiceSupport 
implements CamelTracingServi
         initTracer();
         initContextPropagators();
         ServiceHelper.startService(eventNotifier);
+
+        if (Boolean.TRUE.equals(camelContext.isUseMDCLogging())) {
+            LOG.warn("Initialized tracing component to put trace_id and 
span_id into MDC. " +
+                     "This is a deprecated feature and may disappear in the 
future. " +
+                     "You should replace it with the specific MDC 
instrumentation provided by your tracing/telemetry SDK instead. "
+                     +
+                     "See the tracing component documentation to learn more 
about it.");
+        }
     }
 
     @Override
diff --git 
a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_10.adoc 
b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_10.adoc
index 65c9bddf9d7..fe30dd9391c 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_10.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_10.adoc
@@ -21,10 +21,14 @@ The camel-jbang commands for `camel-k` has been removed.
 
 === camel-google-pubsub-lite
 
-The component `camel-google-pubsub-lite` has been deprecated following the 
deprecation of the corresponding service by Google Cloud Platform. 
+The component `camel-google-pubsub-lite` has been deprecated following the 
deprecation of the corresponding service by Google Cloud Platform.
 
 Google recommends migrating your Pub/Sub Lite service to either Google Cloud 
Managed Service for Apache Kafka or Google Cloud Pub/Sub. Depending on your 
choice, you should use `camel-kafka` or `camel-google-pubsub component`, 
respectively.
 
 == camel-spring-boot
 
 The `camel-k-starter` has been removed.
+
+=== camel-tracing
+
+We have deprecated the setting of MDC `trace_id` and `span_id` in favour of 
implementation specific feature. You need to check the specific 
tracing/telemetry component configuration to learn how to switch from the 
deprecated configuration to the new one. Most of the time you will need to 
remove the `camel.main.use-mdc-logging` Camel property (or set it to `false`) 
and add dependencies and configuration settings to enable the specific 
component instrumentation.
diff --git a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide.adoc 
b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide.adoc
index d1e264fb7ee..0645d3df09f 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide.adoc
@@ -19,4 +19,3 @@ You can find the upgrade guide for each release in the 
following pages:
 - xref:camel-4x-upgrade-guide-4_8.adoc[Upgrade guide 4.7 -> 4.8]
 - xref:camel-4x-upgrade-guide-4_9.adoc[Upgrade guide 4.8 -> 4.9]
 - xref:camel-4x-upgrade-guide-4_10.adoc[Upgrade guide 4.9 -> 4.10]
-

Reply via email to