[ https://issues.apache.org/jira/browse/CAMEL-21472?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17901949#comment-17901949 ]
Pasquale Congiusti commented on CAMEL-21472: -------------------------------------------- Okey, I think I have a fair understanding of what's going on. The problem is not with the tracing propagation at all. The telemetry is correctly creating the expected traces that can be later recovered in the OTEL collection. According to some troubleshooting I've done raising log levels of the application, every exchange creates a trace_id correctly and each event create a span_id bound to the exchange trace_id. The problem indeed is with MDC which is not able to perform the same propagation mechanism used by the telemetry. This is something expected as the MDC stores values at each thread level. As soon as the core starts a new thread to manage some event (like it happens with the direct routes), then, the MDC is started from scratch, loosing those values or reusing any previous value set there. This is the reason why we either see empty traces or traces coming from previous threads executions. In general it seems the OTEL has [some mechanism to manage MDC context directly|https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/docs/logger-mdc-instrumentation.md]. However, I've quickly tested on Camel Main and it suffer the same problems we have when using our own solution. IMO, we should remove the feature at all as this is leading to inconsistencies which I am not sure we can really solve. We should remainder the user to use the specific telemetry instrumentation that is available for such a purpose instead. > Opentelemetry is using the same traceId when exchange is fired from file or > timer component > ------------------------------------------------------------------------------------------- > > Key: CAMEL-21472 > URL: https://issues.apache.org/jira/browse/CAMEL-21472 > Project: Camel > Issue Type: Bug > Components: camel-opentelemetry > Affects Versions: 4.8.1 > Reporter: Thomas Gantenbein > Assignee: Pasquale Congiusti > Priority: Major > Fix For: 4.8.3, 4.10.0 > > Attachments: image-2024-11-26-09-59-35-555.png > > > *Problem* > When using a consumer like {{timer}} or {{{}file{}}}, the traceId remains the > same for all messages. When using a consumer like netty (or, I assume, any > other http/tcp-based consumer), every call gets its own traceId as expected. > See also > https://camel.zulipchat.com/#narrow/channel/257298-camel/topic/Same.20OTEL.20trace.20for.20all.20messages.20into.20IBM.20MQ > *Reproducer* > [https://github.com/thomas-gantenbein-tga/camel-opentelemetry/tree/main] > [~pcongiusti], thanks for your answer on Zulip Chat. Let me know if I should > further explain or minimize that reproducer. -- This message was sent by Atlassian Jira (v8.20.10#820010)