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

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


The following commit(s) were added to refs/heads/camel-4.14.x by this push:
     new acc0a33d8f8 fix(components): Telemetry polling requests
acc0a33d8f8 is described below

commit acc0a33d8f8d8fe0cf7fa6e70367f055f3e408dc
Author: Pasquale Congiusti <[email protected]>
AuthorDate: Tue Sep 2 12:39:30 2025 +0200

    fix(components): Telemetry polling requests
    
    Use an empty InterceptStrategy in order to include any component polling 
requests under the correct trace.
    
    Closes CAMEL-22385
---
 .../telemetry/TraceProcessorsInterceptStrategy.java      |  4 +++-
 .../src/main/java/org/apache/camel/telemetry/Tracer.java |  7 +++++--
 ...ceptStrategy.java => WrapPollsInterceptStrategy.java} | 16 +++++++---------
 3 files changed, 15 insertions(+), 12 deletions(-)

diff --git 
a/components/camel-telemetry/src/main/java/org/apache/camel/telemetry/TraceProcessorsInterceptStrategy.java
 
b/components/camel-telemetry/src/main/java/org/apache/camel/telemetry/TraceProcessorsInterceptStrategy.java
index b4b2aad5563..6d560de3aad 100644
--- 
a/components/camel-telemetry/src/main/java/org/apache/camel/telemetry/TraceProcessorsInterceptStrategy.java
+++ 
b/components/camel-telemetry/src/main/java/org/apache/camel/telemetry/TraceProcessorsInterceptStrategy.java
@@ -23,6 +23,9 @@ import org.apache.camel.Processor;
 import org.apache.camel.spi.InterceptStrategy;
 import org.apache.camel.support.processor.DelegateAsyncProcessor;
 
+/**
+ * TraceProcessorsInterceptStrategy is used to wrap each processor calls and 
generate a Span for each process execution.
+ */
 public class TraceProcessorsInterceptStrategy implements InterceptStrategy {
 
     private Tracer tracer;
@@ -36,7 +39,6 @@ public class TraceProcessorsInterceptStrategy implements 
InterceptStrategy {
             CamelContext camelContext,
             NamedNode processorDefinition, Processor target, Processor 
nextTarget)
             throws Exception {
-        //return new TraceProcessor(target, processorDefinition);
         return new DelegateAsyncProcessor(new TraceProcessor(target, 
processorDefinition));
     }
 
diff --git 
a/components/camel-telemetry/src/main/java/org/apache/camel/telemetry/Tracer.java
 
b/components/camel-telemetry/src/main/java/org/apache/camel/telemetry/Tracer.java
index 6b878f4b900..c16da510692 100644
--- 
a/components/camel-telemetry/src/main/java/org/apache/camel/telemetry/Tracer.java
+++ 
b/components/camel-telemetry/src/main/java/org/apache/camel/telemetry/Tracer.java
@@ -145,10 +145,13 @@ public abstract class Tracer extends ServiceSupport 
implements CamelTracingServi
             camelContext.addRoutePolicyFactory(this);
         }
         camelContext.getCamelContextExtension().addLogListener(new 
TracingLogListener());
+        InterceptStrategy interceptStrategy;
         if (isTraceProcessors()) {
-            InterceptStrategy traceProcessorsStrategy = new 
TraceProcessorsInterceptStrategy(this);
-            
camelContext.getCamelContextExtension().addInterceptStrategy(traceProcessorsStrategy);
+            interceptStrategy = new TraceProcessorsInterceptStrategy(this);
+        } else {
+            interceptStrategy = new WrapPollsInterceptStrategy(this);
         }
+        
camelContext.getCamelContextExtension().addInterceptStrategy(interceptStrategy);
         initTracer();
         ServiceHelper.startService(eventNotifier);
     }
diff --git 
a/components/camel-telemetry/src/main/java/org/apache/camel/telemetry/TraceProcessorsInterceptStrategy.java
 
b/components/camel-telemetry/src/main/java/org/apache/camel/telemetry/WrapPollsInterceptStrategy.java
similarity index 82%
copy from 
components/camel-telemetry/src/main/java/org/apache/camel/telemetry/TraceProcessorsInterceptStrategy.java
copy to 
components/camel-telemetry/src/main/java/org/apache/camel/telemetry/WrapPollsInterceptStrategy.java
index b4b2aad5563..197ebd44045 100644
--- 
a/components/camel-telemetry/src/main/java/org/apache/camel/telemetry/TraceProcessorsInterceptStrategy.java
+++ 
b/components/camel-telemetry/src/main/java/org/apache/camel/telemetry/WrapPollsInterceptStrategy.java
@@ -23,11 +23,15 @@ import org.apache.camel.Processor;
 import org.apache.camel.spi.InterceptStrategy;
 import org.apache.camel.support.processor.DelegateAsyncProcessor;
 
-public class TraceProcessorsInterceptStrategy implements InterceptStrategy {
+/**
+ * WrapPollsInterceptStrategy is used for any regular process in order to 
include any potential external generated trace
+ * (for instance, any http call used in polling components) under the specific 
trace parent.
+ */
+public class WrapPollsInterceptStrategy implements InterceptStrategy {
 
     private Tracer tracer;
 
-    public TraceProcessorsInterceptStrategy(Tracer tracer) {
+    public WrapPollsInterceptStrategy(Tracer tracer) {
         this.tracer = tracer;
     }
 
@@ -36,7 +40,6 @@ public class TraceProcessorsInterceptStrategy implements 
InterceptStrategy {
             CamelContext camelContext,
             NamedNode processorDefinition, Processor target, Processor 
nextTarget)
             throws Exception {
-        //return new TraceProcessor(target, processorDefinition);
         return new DelegateAsyncProcessor(new TraceProcessor(target, 
processorDefinition));
     }
 
@@ -53,12 +56,7 @@ public class TraceProcessorsInterceptStrategy implements 
InterceptStrategy {
         public void process(Exchange exchange) throws Exception {
             String processor = processorDefinition.getId() + "-" + 
processorDefinition.getShortName();
             if (!tracer.exclude(processor, exchange.getContext())) {
-                tracer.beginProcessorSpan(exchange, processor);
-                try {
-                    target.process(exchange);
-                } finally {
-                    tracer.endProcessorSpan(exchange, processor);
-                }
+                target.process(exchange);
             }
         }
     }

Reply via email to