Skip to content

Commit

Permalink
feat(components): deprecate tracing MDC
Browse files Browse the repository at this point in the history
Favoring instead the instrumentation provided into each specific tracing framework.

Closes CAMEL-21538
  • Loading branch information
squakez committed Dec 17, 2024
1 parent 00cecd7 commit c6ec694
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 4 deletions.
4 changes: 3 additions & 1 deletion components/camel-observation/src/main/docs/observation.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
3 changes: 3 additions & 0 deletions components/camel-tracing/src/main/docs/tracing.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@
*/
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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,14 @@ protected void doInit() {
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Original file line number Diff line number Diff line change
Expand Up @@ -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]

0 comments on commit c6ec694

Please sign in to comment.