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 f55cec6ba932 chore(components): trace processors enhancement
f55cec6ba932 is described below
commit f55cec6ba93205b07d0ac9a6700da40fb254cab2
Author: Pasquale Congiusti <[email protected]>
AuthorDate: Mon Oct 20 12:22:16 2025 +0200
chore(components): trace processors enhancement
---
.../TraceProcessorsInterceptStrategy.java | 3 +-
.../java/org/apache/camel/telemetry/Tracer.java | 8 +--
.../telemetry/WrapPollsInterceptStrategy.java | 64 ----------------------
3 files changed, 4 insertions(+), 71 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 900c815ffb04..e10c6d1a22e0 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
@@ -54,7 +54,7 @@ public class TraceProcessorsInterceptStrategy implements
InterceptStrategy {
@Override
public void process(Exchange exchange) throws Exception {
String processor = processorDefinition.getId() + "-" +
processorDefinition.getShortName();
- if (!tracer.exclude(processor, exchange.getContext())) {
+ if (tracer.isTraceProcessors() && !tracer.exclude(processor,
exchange.getContext())) {
tracer.beginProcessorSpan(exchange, processor);
try {
target.process(exchange);
@@ -62,6 +62,7 @@ public class TraceProcessorsInterceptStrategy implements
InterceptStrategy {
tracer.endProcessorSpan(exchange, processor);
}
} else {
+ // We must always execute this
target.process(exchange);
}
}
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 c16da5106925..eb608a08434f 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,13 +145,9 @@ public abstract class Tracer extends ServiceSupport
implements CamelTracingServi
camelContext.addRoutePolicyFactory(this);
}
camelContext.getCamelContextExtension().addLogListener(new
TracingLogListener());
- InterceptStrategy interceptStrategy;
- if (isTraceProcessors()) {
- interceptStrategy = new TraceProcessorsInterceptStrategy(this);
- } else {
- interceptStrategy = new WrapPollsInterceptStrategy(this);
- }
+ InterceptStrategy interceptStrategy = new
TraceProcessorsInterceptStrategy(this);
camelContext.getCamelContextExtension().addInterceptStrategy(interceptStrategy);
+
initTracer();
ServiceHelper.startService(eventNotifier);
}
diff --git
a/components/camel-telemetry/src/main/java/org/apache/camel/telemetry/WrapPollsInterceptStrategy.java
b/components/camel-telemetry/src/main/java/org/apache/camel/telemetry/WrapPollsInterceptStrategy.java
deleted file mode 100644
index 197ebd44045a..000000000000
---
a/components/camel-telemetry/src/main/java/org/apache/camel/telemetry/WrapPollsInterceptStrategy.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * 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.telemetry;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.Exchange;
-import org.apache.camel.NamedNode;
-import org.apache.camel.Processor;
-import org.apache.camel.spi.InterceptStrategy;
-import org.apache.camel.support.processor.DelegateAsyncProcessor;
-
-/**
- * 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 WrapPollsInterceptStrategy(Tracer tracer) {
- this.tracer = tracer;
- }
-
- @Override
- public Processor wrapProcessorInInterceptors(
- CamelContext camelContext,
- NamedNode processorDefinition, Processor target, Processor
nextTarget)
- throws Exception {
- return new DelegateAsyncProcessor(new TraceProcessor(target,
processorDefinition));
- }
-
- private class TraceProcessor implements Processor {
- private final NamedNode processorDefinition;
- private final Processor target;
-
- public TraceProcessor(Processor target, NamedNode processorDefinition)
{
- this.target = target;
- this.processorDefinition = processorDefinition;
- }
-
- @Override
- public void process(Exchange exchange) throws Exception {
- String processor = processorDefinition.getId() + "-" +
processorDefinition.getShortName();
- if (!tracer.exclude(processor, exchange.getContext())) {
- target.process(exchange);
- }
- }
- }
-
-}