You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by pc...@apache.org on 2026/05/08 07:11:18 UTC
(camel) 06/06: chore(components): micrometer-observability core processors
This is an automated email from the ASF dual-hosted git repository.
squakez pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 4c1d043150731d63091177275f53b46e44a54b2f
Author: Pasquale Congiusti <pa...@gmail.com>
AuthorDate: Thu May 7 11:15:03 2026 +0200
chore(components): micrometer-observability core processors
Ref CAMEL-23432
---
.../MicrometerObservabilityTracerConfigurer.java | 6 +++
.../src/main/docs/micrometer-observability.adoc | 5 ++-
.../observability/BaggageInjectionTest.java | 5 ++-
.../observability/EnableProcessorsTest.java | 5 ++-
...rObservabilityTracerPropagationTestSupport.java | 1 +
...panCustomizationTest.java => SpanBeanTest.java} | 44 +++++++++++++---------
.../observability/SpanCustomizationTest.java | 5 ++-
.../observability/SpanInjectionTest.java | 5 ++-
.../java/org/apache/camel/telemetry/Tracer.java | 2 +-
proposals/tracing.adoc | 8 +---
10 files changed, 55 insertions(+), 31 deletions(-)
diff --git a/components/camel-micrometer-observability/src/generated/java/org/apache/camel/micrometer/observability/MicrometerObservabilityTracerConfigurer.java b/components/camel-micrometer-observability/src/generated/java/org/apache/camel/micrometer/observability/MicrometerObservabilityTracerConfigurer.java
index 81a5e30fb4b1..35a9d8baf3a8 100644
--- a/components/camel-micrometer-observability/src/generated/java/org/apache/camel/micrometer/observability/MicrometerObservabilityTracerConfigurer.java
+++ b/components/camel-micrometer-observability/src/generated/java/org/apache/camel/micrometer/observability/MicrometerObservabilityTracerConfigurer.java
@@ -25,6 +25,8 @@ public class MicrometerObservabilityTracerConfigurer extends org.apache.camel.su
switch (ignoreCase ? name.toLowerCase() : name) {
case "camelcontext":
case "camelContext": target.setCamelContext(property(camelContext, org.apache.camel.CamelContext.class, value)); return true;
+ case "disablecoreprocessors":
+ case "disableCoreProcessors": target.setDisableCoreProcessors(property(camelContext, boolean.class, value)); return true;
case "excludepatterns":
case "excludePatterns": target.setExcludePatterns(property(camelContext, java.lang.String.class, value)); return true;
case "observationregistry":
@@ -46,6 +48,8 @@ public class MicrometerObservabilityTracerConfigurer extends org.apache.camel.su
switch (ignoreCase ? name.toLowerCase() : name) {
case "camelcontext":
case "camelContext": return org.apache.camel.CamelContext.class;
+ case "disablecoreprocessors":
+ case "disableCoreProcessors": return boolean.class;
case "excludepatterns":
case "excludePatterns": return java.lang.String.class;
case "observationregistry":
@@ -68,6 +72,8 @@ public class MicrometerObservabilityTracerConfigurer extends org.apache.camel.su
switch (ignoreCase ? name.toLowerCase() : name) {
case "camelcontext":
case "camelContext": return target.getCamelContext();
+ case "disablecoreprocessors":
+ case "disableCoreProcessors": return target.isDisableCoreProcessors();
case "excludepatterns":
case "excludePatterns": return target.getExcludePatterns();
case "observationregistry":
diff --git a/components/camel-micrometer-observability/src/main/docs/micrometer-observability.adoc b/components/camel-micrometer-observability/src/main/docs/micrometer-observability.adoc
index 017e1b79b822..45bf7e99be2b 100644
--- a/components/camel-micrometer-observability/src/main/docs/micrometer-observability.adoc
+++ b/components/camel-micrometer-observability/src/main/docs/micrometer-observability.adoc
@@ -28,9 +28,10 @@ The configuration properties for the component are:
[width="100%",cols="10%,10%,80%",options="header",]
|=======================================================================
|Option |Default |Description
+|`enabled`| false | Turn the tracing on/off.
+|`traceProcessors`| false | Trace inner custom processors (i.e., any `process` configured in the route).
+|`disableCoreProcessors`| false | Disable any inner core processors (any core DSL processor provided in the route, for example `bean`, `log`, ...).
|`excludePatterns` | | Sets exclude pattern that will disable tracing for those spans that matches the pattern. The variable is a comma separated values of filters to execute (eg, `log*,direct*,setBody*`, ...)
-|`traceProcessors` | `false` | Setting this to true will create new spans for each Camel Processors.
-Use the excludePattern property to filter out Processors
|`traceHeadersInclusion`| false | Add the generated telemetry `CAMEL_TRACE_ID` and `CAMEL_SPAN_ID` Exchange headers.
|=======================================================================
diff --git a/components/camel-micrometer-observability/src/test/java/org/apache/camel/micrometer/observability/BaggageInjectionTest.java b/components/camel-micrometer-observability/src/test/java/org/apache/camel/micrometer/observability/BaggageInjectionTest.java
index 0fa31081e97e..c83666f608d0 100644
--- a/components/camel-micrometer-observability/src/test/java/org/apache/camel/micrometer/observability/BaggageInjectionTest.java
+++ b/components/camel-micrometer-observability/src/test/java/org/apache/camel/micrometer/observability/BaggageInjectionTest.java
@@ -44,8 +44,11 @@ public class BaggageInjectionTest extends MicrometerObservabilityTracerPropagati
@Override
protected CamelContext createCamelContext() throws Exception {
+ CamelContext ctx = super.createCamelContext();
tst.setTraceProcessors(true);
- return super.createCamelContext();
+ tst.setDisableCoreProcessors(false);
+
+ return ctx;
}
@Test
diff --git a/components/camel-micrometer-observability/src/test/java/org/apache/camel/micrometer/observability/EnableProcessorsTest.java b/components/camel-micrometer-observability/src/test/java/org/apache/camel/micrometer/observability/EnableProcessorsTest.java
index 84395878723b..13b42a399b8b 100644
--- a/components/camel-micrometer-observability/src/test/java/org/apache/camel/micrometer/observability/EnableProcessorsTest.java
+++ b/components/camel-micrometer-observability/src/test/java/org/apache/camel/micrometer/observability/EnableProcessorsTest.java
@@ -39,8 +39,11 @@ public class EnableProcessorsTest extends MicrometerObservabilityTracerPropagati
@Override
protected CamelContext createCamelContext() throws Exception {
+ CamelContext ctx = super.createCamelContext();
tst.setTraceProcessors(true);
- return super.createCamelContext();
+ tst.setDisableCoreProcessors(false);
+
+ return ctx;
}
@Test
diff --git a/components/camel-micrometer-observability/src/test/java/org/apache/camel/micrometer/observability/MicrometerObservabilityTracerPropagationTestSupport.java b/components/camel-micrometer-observability/src/test/java/org/apache/camel/micrometer/observability/MicrometerObservabilityTracerPropagationTestSupport.java
index f5b266408de9..b99d1c8c2e6e 100644
--- a/components/camel-micrometer-observability/src/test/java/org/apache/camel/micrometer/observability/MicrometerObservabilityTracerPropagationTestSupport.java
+++ b/components/camel-micrometer-observability/src/test/java/org/apache/camel/micrometer/observability/MicrometerObservabilityTracerPropagationTestSupport.java
@@ -74,6 +74,7 @@ public class MicrometerObservabilityTracerPropagationTestSupport extends Exchang
CamelContextAware.trySetCamelContext(tst, context);
tst.init(context);
+ tst.setDisableCoreProcessors(true);
return context;
}
diff --git a/components/camel-micrometer-observability/src/test/java/org/apache/camel/micrometer/observability/SpanCustomizationTest.java b/components/camel-micrometer-observability/src/test/java/org/apache/camel/micrometer/observability/SpanBeanTest.java
similarity index 76%
copy from components/camel-micrometer-observability/src/test/java/org/apache/camel/micrometer/observability/SpanCustomizationTest.java
copy to components/camel-micrometer-observability/src/test/java/org/apache/camel/micrometer/observability/SpanBeanTest.java
index 8e866bbf8d37..aedb256e9f2c 100644
--- a/components/camel-micrometer-observability/src/test/java/org/apache/camel/micrometer/observability/SpanCustomizationTest.java
+++ b/components/camel-micrometer-observability/src/test/java/org/apache/camel/micrometer/observability/SpanBeanTest.java
@@ -20,7 +20,6 @@ import java.io.IOException;
import java.util.List;
import java.util.Map;
-import io.micrometer.tracing.Span;
import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.sdk.trace.data.SpanData;
import org.apache.camel.CamelContext;
@@ -36,12 +35,14 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
-public class SpanCustomizationTest extends MicrometerObservabilityTracerPropagationTestSupport {
+public class SpanBeanTest extends MicrometerObservabilityTracerPropagationTestSupport {
@Override
protected CamelContext createCamelContext() throws Exception {
- tst.setTraceProcessors(true);
- return super.createCamelContext();
+ CamelContext ctx = super.createCamelContext();
+ tst.setDisableCoreProcessors(false);
+
+ return ctx;
}
@Test
@@ -58,7 +59,7 @@ public class SpanCustomizationTest extends MicrometerObservabilityTracerPropagat
SpanData testProducer = spans.get(0);
SpanData direct = spans.get(1);
SpanData innerLog = spans.get(2);
- SpanData innerProcessor = spans.get(3);
+ SpanData beanProcessor = spans.get(3);
SpanData customSpan = spans.get(4);
SpanData log = spans.get(5);
SpanData innerToLog = spans.get(6);
@@ -67,7 +68,7 @@ public class SpanCustomizationTest extends MicrometerObservabilityTracerPropagat
assertTrue(testProducer.hasEnded());
assertTrue(direct.hasEnded());
assertTrue(innerLog.hasEnded());
- assertTrue(innerProcessor.hasEnded());
+ assertTrue(beanProcessor.hasEnded());
assertTrue(customSpan.hasEnded());
assertTrue(log.hasEnded());
assertTrue(innerToLog.hasEnded());
@@ -76,20 +77,20 @@ public class SpanCustomizationTest extends MicrometerObservabilityTracerPropagat
assertEquals(testProducer.getSpanContext().getTraceId(), direct.getSpanContext().getTraceId());
assertEquals(testProducer.getSpanContext().getTraceId(), direct.getSpanContext().getTraceId());
assertEquals(testProducer.getSpanContext().getTraceId(), innerLog.getSpanContext().getTraceId());
- assertEquals(testProducer.getSpanContext().getTraceId(), innerProcessor.getSpanContext().getTraceId());
+ assertEquals(testProducer.getSpanContext().getTraceId(), beanProcessor.getSpanContext().getTraceId());
assertEquals(testProducer.getSpanContext().getTraceId(), customSpan.getSpanContext().getTraceId());
assertEquals(testProducer.getSpanContext().getTraceId(), log.getSpanContext().getTraceId());
assertEquals(testProducer.getSpanContext().getTraceId(), innerToLog.getSpanContext().getTraceId());
// Validate operations
assertEquals(Op.EVENT_RECEIVED.toString(), direct.getAttributes().get(AttributeKey.stringKey("op")));
- assertEquals(Op.EVENT_PROCESS.toString(), innerProcessor.getAttributes().get(AttributeKey.stringKey("op")));
+ assertEquals(Op.EVENT_PROCESS.toString(), beanProcessor.getAttributes().get(AttributeKey.stringKey("op")));
// Validate hierarchy
assertFalse(testProducer.getParentSpanContext().isValid());
assertEquals(testProducer.getSpanContext().getSpanId(), direct.getParentSpanContext().getSpanId());
- assertEquals(direct.getSpanContext().getSpanId(), innerProcessor.getParentSpanContext().getSpanId());
- assertEquals(innerProcessor.getSpanContext().getSpanId(), customSpan.getParentSpanContext().getSpanId());
+ assertEquals(direct.getSpanContext().getSpanId(), beanProcessor.getParentSpanContext().getSpanId());
+ assertEquals(beanProcessor.getSpanContext().getSpanId(), customSpan.getParentSpanContext().getSpanId());
// Validate custom span
assertEquals("mySpan", customSpan.getName());
@@ -100,23 +101,32 @@ public class SpanCustomizationTest extends MicrometerObservabilityTracerPropagat
return new RouteBuilder() {
@Override
public void configure() {
+ MyBean myBean = new MyBean();
+ this.getCamelContext().getRegistry().bind("myBean", myBean);
+
from("direct:start")
.routeId("start")
.log("A message")
+ .bean(MyBean.class)
.process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
- exchange.getIn().setHeader("operation", "fake");
- // We add a span during the processing. We need to verify this span is correctly
- // created and belong to the proper hierarchy. Important: the user has to know which is the
- // tracer, likely, setting it on the camel-telemetry Tracer component explicitly.
- Span mySpan = tracer.nextSpan().name("mySpan").start();
- // Do the work here
- mySpan.end();
+ // noop
}
})
.to("log:info");
}
};
}
+
+ class MyBean {
+ // NOTE: the commented annotation below would work only when an agent or a runtime framework (quarkus or spring)
+ // is available. We simulate it creating the Span by hand instead.
+ //@WithSpan
+ public void helloWorld() {
+ io.opentelemetry.api.trace.Span mySpan = otelTracer.spanBuilder("mySpan").startSpan();
+ // Do the work here
+ mySpan.end();
+ }
+ }
}
diff --git a/components/camel-micrometer-observability/src/test/java/org/apache/camel/micrometer/observability/SpanCustomizationTest.java b/components/camel-micrometer-observability/src/test/java/org/apache/camel/micrometer/observability/SpanCustomizationTest.java
index 8e866bbf8d37..4b86e4480cfc 100644
--- a/components/camel-micrometer-observability/src/test/java/org/apache/camel/micrometer/observability/SpanCustomizationTest.java
+++ b/components/camel-micrometer-observability/src/test/java/org/apache/camel/micrometer/observability/SpanCustomizationTest.java
@@ -40,8 +40,11 @@ public class SpanCustomizationTest extends MicrometerObservabilityTracerPropagat
@Override
protected CamelContext createCamelContext() throws Exception {
+ CamelContext ctx = super.createCamelContext();
tst.setTraceProcessors(true);
- return super.createCamelContext();
+ tst.setDisableCoreProcessors(false);
+
+ return ctx;
}
@Test
diff --git a/components/camel-micrometer-observability/src/test/java/org/apache/camel/micrometer/observability/SpanInjectionTest.java b/components/camel-micrometer-observability/src/test/java/org/apache/camel/micrometer/observability/SpanInjectionTest.java
index 3a236df892dd..908b5343c312 100644
--- a/components/camel-micrometer-observability/src/test/java/org/apache/camel/micrometer/observability/SpanInjectionTest.java
+++ b/components/camel-micrometer-observability/src/test/java/org/apache/camel/micrometer/observability/SpanInjectionTest.java
@@ -43,8 +43,11 @@ public class SpanInjectionTest extends MicrometerObservabilityTracerPropagationT
@Override
protected CamelContext createCamelContext() throws Exception {
+ CamelContext ctx = super.createCamelContext();
tst.setTraceProcessors(true);
- return super.createCamelContext();
+ tst.setDisableCoreProcessors(false);
+
+ return ctx;
}
@Test
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 6b2af88b9dd2..9677ee55e505 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
@@ -56,7 +56,7 @@ public abstract class Tracer extends ServiceSupport implements CamelTracingServi
*/
private String excludePatterns;
private boolean traceProcessors;
- private boolean disableCoreProcessors = false;
+ private boolean disableCoreProcessors;
private boolean traceHeadersInclusion;
private final TracingEventNotifier eventNotifier = new TracingEventNotifier();
diff --git a/proposals/tracing.adoc b/proposals/tracing.adoc
index 2dad31f57653..9d91978df7e2 100644
--- a/proposals/tracing.adoc
+++ b/proposals/tracing.adoc
@@ -9,7 +9,7 @@ approvers:
- "@zbendhiba"
- "@davsclaus"
creation-date: 2025-01-08
-last-updated: 2026-05-07
+last-updated: 2026-05-04
status: implemented
see-also: []
replaces: []
@@ -167,9 +167,3 @@ As described in https://issues.apache.org/jira/browse/CAMEL-23380 any version be
In order to prevent this problem we need to rethink the implementation details of `camel-opentelemetry2` and remove the explicit `Scope` management that, when asynchronous, was opening the `Scope` in a thread and closing in another (what we had called "dirty" context). We are now removing this explicit management and moving this part exclusively in the custom Camel `Processors`. Here Camel will take care to open the Opentelemetry scope and close it within the same thread.
What it means is that, from now on we get rid of the leak but the final user or any third party dependency can only access the Opentelemetry context within the boundary of a Processor execution.
-
-=== Distinguish custom Processors from core Processors (2026-05-07)
-
-The custom processors must be distinguished from core processors in order to let the user disable span generation only for custom processors. This is an **important design constraint** required to ensure that the core processors spans are always generated during an execution. With this constraint we ensure that any third party instrumentation span (which generally happens at core Processor level) is correctly nested.
-
-Disabling this feature is possible and could work for simple tracing. However it is not recommended and the user should always fine tune the exclusions of processors explicitly in case he wants to reduce the number of generated spans.