Re: [PR] chore(components): specify custom span nesting in opentelemetry [camel]

2026-05-12 Thread via GitHub


squakez merged PR #23120:
URL: https://github.com/apache/camel/pull/23120


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] chore(components): specify custom span nesting in opentelemetry [camel]

2026-05-12 Thread via GitHub


squakez commented on code in PR #23120:
URL: https://github.com/apache/camel/pull/23120#discussion_r3224560634


##
components/camel-telemetry/src/test/java/org/apache/camel/telemetry/SpanToBeanTest.java:
##
@@ -0,0 +1,151 @@
+/*
+ * 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 java.util.List;
+import java.util.Map;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.CamelContextAware;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.RoutesBuilder;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.telemetry.mock.MockSpanAdapter;
+import org.apache.camel.telemetry.mock.MockTrace;
+import org.apache.camel.telemetry.mock.MockTracer;
+import org.apache.camel.test.junit6.ExchangeTestSupport;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
+public class SpanToBeanTest extends ExchangeTestSupport {
+
+MockTracer mockTracer;
+
+@Override
+protected CamelContext createCamelContext() throws Exception {
+CamelContext context = super.createCamelContext();
+this.mockTracer = new MockTracer();
+CamelContextAware.trySetCamelContext(mockTracer, context);
+mockTracer.init(context);
+return context;
+}
+
+@Test
+void testProcessorsTraceRequest() {
+template.sendBody("direct:start", "my-body");
+Map traces = mockTracer.traces();
+assertEquals(1, traces.size());
+checkTrace(traces.values().iterator().next());
+}
+
+private void checkTrace(MockTrace trace) {
+List spans = trace.spans();
+assertEquals(8, spans.size());
+// Cast to implementation object to be able to
+// inspect the status of the Span.
+MockSpanAdapter testProducer = (MockSpanAdapter) spans.get(0);
+MockSpanAdapter direct = (MockSpanAdapter) spans.get(1);
+MockSpanAdapter innerLog = (MockSpanAdapter) spans.get(2);
+MockSpanAdapter toBean = (MockSpanAdapter) spans.get(3);
+MockSpanAdapter bean = (MockSpanAdapter) spans.get(4);
+MockSpanAdapter beanMethod = (MockSpanAdapter) spans.get(5);
+MockSpanAdapter log = (MockSpanAdapter) spans.get(6);
+MockSpanAdapter innerToLog = (MockSpanAdapter) spans.get(7);
+
+// Validate span completion
+assertEquals("true", testProducer.getTag("isDone"));
+assertEquals("true", direct.getTag("isDone"));
+assertEquals("true", innerLog.getTag("isDone"));
+assertEquals("true", toBean.getTag("isDone"));
+assertEquals("true", bean.getTag("isDone"));
+assertEquals("true", beanMethod.getTag("isDone"));
+assertEquals("true", log.getTag("isDone"));
+assertEquals("true", innerToLog.getTag("isDone"));
+
+// Validate same trace
+assertEquals(testProducer.getTag("traceid"), direct.getTag("traceid"));
+assertEquals(testProducer.getTag("traceid"), 
innerLog.getTag("traceid"));
+assertEquals(testProducer.getTag("traceid"), log.getTag("traceid"));
+assertEquals(testProducer.getTag("traceid"), toBean.getTag("traceid"));
+assertEquals(testProducer.getTag("traceid"), bean.getTag("traceid"));
+assertEquals(testProducer.getTag("traceid"), 
beanMethod.getTag("traceid"));
+assertEquals(testProducer.getTag("traceid"), 
innerToLog.getTag("traceid"));
+
+// Validate op
+assertEquals(Op.EVENT_RECEIVED.toString(), direct.getTag("op"));
+
+// Validate hierarchy
+assertNull(testProducer.getTag("parentSpan"));
+assertEquals(testProducer.getTag("spanid"), 
direct.getTag("parentSpan"));
+assertEquals(direct.getTag("spanid"), innerLog.getTag("parentSpan"));
+assertEquals(direct.getTag("spanid"), log.getTag("parentSpan"));
+assertEquals(direct.getTag("spanid"), toBean.getTag("parentSpan"));
+assertEquals(toBean.getTag("spanid"), bean.getTag("parentSpan"));
+assertEquals(bean.getTag("spanid"), beanMethod.getTag("parentSpan"));
+assertEquals(log.g

Re: [PR] chore(components): specify custom span nesting in opentelemetry [camel]

2026-05-12 Thread via GitHub


squakez commented on code in PR #23120:
URL: https://github.com/apache/camel/pull/23120#discussion_r3224553738


##
components/camel-telemetry/src/test/java/org/apache/camel/telemetry/SpanToBeanTest.java:
##
@@ -0,0 +1,151 @@
+/*
+ * 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 java.util.List;
+import java.util.Map;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.CamelContextAware;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.RoutesBuilder;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.telemetry.mock.MockSpanAdapter;
+import org.apache.camel.telemetry.mock.MockTrace;
+import org.apache.camel.telemetry.mock.MockTracer;
+import org.apache.camel.test.junit6.ExchangeTestSupport;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
+public class SpanToBeanTest extends ExchangeTestSupport {
+
+MockTracer mockTracer;
+
+@Override
+protected CamelContext createCamelContext() throws Exception {
+CamelContext context = super.createCamelContext();
+this.mockTracer = new MockTracer();
+CamelContextAware.trySetCamelContext(mockTracer, context);
+mockTracer.init(context);
+return context;
+}
+
+@Test
+void testProcessorsTraceRequest() {
+template.sendBody("direct:start", "my-body");
+Map traces = mockTracer.traces();
+assertEquals(1, traces.size());
+checkTrace(traces.values().iterator().next());
+}
+
+private void checkTrace(MockTrace trace) {
+List spans = trace.spans();
+assertEquals(8, spans.size());
+// Cast to implementation object to be able to
+// inspect the status of the Span.
+MockSpanAdapter testProducer = (MockSpanAdapter) spans.get(0);
+MockSpanAdapter direct = (MockSpanAdapter) spans.get(1);
+MockSpanAdapter innerLog = (MockSpanAdapter) spans.get(2);
+MockSpanAdapter toBean = (MockSpanAdapter) spans.get(3);
+MockSpanAdapter bean = (MockSpanAdapter) spans.get(4);
+MockSpanAdapter beanMethod = (MockSpanAdapter) spans.get(5);
+MockSpanAdapter log = (MockSpanAdapter) spans.get(6);
+MockSpanAdapter innerToLog = (MockSpanAdapter) spans.get(7);
+
+// Validate span completion
+assertEquals("true", testProducer.getTag("isDone"));
+assertEquals("true", direct.getTag("isDone"));
+assertEquals("true", innerLog.getTag("isDone"));
+assertEquals("true", toBean.getTag("isDone"));
+assertEquals("true", bean.getTag("isDone"));
+assertEquals("true", beanMethod.getTag("isDone"));
+assertEquals("true", log.getTag("isDone"));
+assertEquals("true", innerToLog.getTag("isDone"));
+
+// Validate same trace
+assertEquals(testProducer.getTag("traceid"), direct.getTag("traceid"));
+assertEquals(testProducer.getTag("traceid"), 
innerLog.getTag("traceid"));
+assertEquals(testProducer.getTag("traceid"), log.getTag("traceid"));
+assertEquals(testProducer.getTag("traceid"), toBean.getTag("traceid"));
+assertEquals(testProducer.getTag("traceid"), bean.getTag("traceid"));
+assertEquals(testProducer.getTag("traceid"), 
beanMethod.getTag("traceid"));
+assertEquals(testProducer.getTag("traceid"), 
innerToLog.getTag("traceid"));
+
+// Validate op
+assertEquals(Op.EVENT_RECEIVED.toString(), direct.getTag("op"));
+
+// Validate hierarchy
+assertNull(testProducer.getTag("parentSpan"));
+assertEquals(testProducer.getTag("spanid"), 
direct.getTag("parentSpan"));
+assertEquals(direct.getTag("spanid"), innerLog.getTag("parentSpan"));
+assertEquals(direct.getTag("spanid"), log.getTag("parentSpan"));
+assertEquals(direct.getTag("spanid"), toBean.getTag("parentSpan"));
+assertEquals(toBean.getTag("spanid"), bean.getTag("parentSpan"));
+assertEquals(bean.getTag("spanid"), beanMethod.getTag("parentSpan"));

Review Comment:
   I don't

Re: [PR] chore(components): specify custom span nesting in opentelemetry [camel]

2026-05-11 Thread via GitHub


gnodet commented on code in PR #23120:
URL: https://github.com/apache/camel/pull/23120#discussion_r3224058471


##
components/camel-opentelemetry2/src/test/java/org/apache/camel/opentelemetry2/SpanToBeanTest.java:
##
@@ -0,0 +1,131 @@
+/*
+ * 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.opentelemetry2;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+
+import io.opentelemetry.api.trace.Span;
+import io.opentelemetry.api.trace.Tracer;
+import io.opentelemetry.sdk.trace.data.SpanData;
+import org.apache.camel.CamelContext;
+import org.apache.camel.CamelContextAware;
+import org.apache.camel.RoutesBuilder;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.opentelemetry2.CamelOpenTelemetryExtension.OtelTrace;
+import org.junit.jupiter.api.Test;
+
+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 SpanToBeanTest extends OpenTelemetryTracerTestSupport {
+
+Tracer tracer = 
otelExtension.getOpenTelemetry().getTracer("spanInjection");
+
+@Override
+protected CamelContext createCamelContext() throws Exception {
+OpenTelemetryTracer tst = new OpenTelemetryTracer();
+tst.setTracer(tracer);
+
tst.setContextPropagators(otelExtension.getOpenTelemetry().getPropagators());
+CamelContext context = super.createCamelContext();
+CamelContextAware.trySetCamelContext(tst, context);
+tst.init(context);
+return context;
+}
+
+@Test
+void testRouteSingleRequest() throws IOException {
+template.sendBody("direct:start", "my-body");
+Map traces = otelExtension.getTraces();
+assertEquals(1, traces.size());
+checkTrace(traces.values().iterator().next());
+}
+
+private void checkTrace(OtelTrace trace) {
+List spans = trace.getSpans();
+assertEquals(8, spans.size());
+SpanData testProducer = spans.get(0);
+SpanData direct = spans.get(1);
+SpanData innerLog = spans.get(2);
+SpanData beanTo = spans.get(3);
+SpanData beanProcessor = spans.get(4);
+SpanData beanMethod = spans.get(5);
+SpanData log = spans.get(6);
+SpanData innerToLog = spans.get(7);
+
+// Validate span completion
+assertTrue(testProducer.hasEnded());
+assertTrue(direct.hasEnded());
+assertTrue(innerLog.hasEnded());
+assertTrue(beanProcessor.hasEnded());

Review Comment:
   `beanTo` is declared on line 66 but its completion is not validated here — 
all other 7 spans are checked. Looks like an oversight.
   
   ```suggestion
   assertTrue(beanTo.hasEnded());
   assertTrue(beanProcessor.hasEnded());
   ```



##
components/camel-opentelemetry2/src/test/java/org/apache/camel/opentelemetry2/SpanToBeanTest.java:
##
@@ -0,0 +1,131 @@
+/*
+ * 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.opentelemetry2;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+
+import io.opentelemetry.api.trace.Span;
+import io.opentelemetry.api.trace.Tracer;
+import io.opentelemetry.sdk.trace.data.SpanData;
+import org.apache.camel.CamelContext;
+import org.apache.camel.CamelContextAware;
+import org.apache.camel.RoutesBuilder;
+import org.apac

Re: [PR] chore(components): specify custom span nesting in opentelemetry [camel]

2026-05-11 Thread via GitHub


github-actions[bot] commented on PR #23120:
URL: https://github.com/apache/camel/pull/23120#issuecomment-4420629172

   
   :test_tube: **CI tested the following changed modules:**
   
   - `components/camel-opentelemetry2`
   - `components/camel-telemetry`
   
   All tested modules (12 modules)
   
   - Camel :: Common Telemetry
   - Camel :: JBang :: MCP
   - Camel :: JBang :: Plugin :: Route Parser
   - Camel :: JBang :: Plugin :: TUI
   - Camel :: JBang :: Plugin :: Validate
   - Camel :: Launcher :: Container
   - Camel :: Micrometer :: Observability 2
   - Camel :: Observability Services
   - Camel :: Opentelemetry 2
   - Camel :: Telemetry :: Dev
   - Camel :: YAML DSL :: Validator
   - Camel :: YAML DSL :: Validator Maven Plugin
   
   
   
   ---
   :gear: [View full build and test 
results](https://github.com/apache/camel/actions/runs/25665123003)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] chore(components): specify custom span nesting in opentelemetry [camel]

2026-05-11 Thread via GitHub


github-actions[bot] commented on PR #23120:
URL: https://github.com/apache/camel/pull/23120#issuecomment-4420382096

   :star2: Thank you for your contribution to the Apache Camel project! :star2:
 :robot: CI automation will test this PR automatically.
   
 :camel: Apache Camel Committers, please review the following items:
   
 * First-time contributors **require MANUAL approval** for the GitHub 
Actions to run
 * You can use the command `/component-test (camel-)component-name1 
(camel-)component-name2..` to request a test from the test bot although they 
are normally detected and executed by CI.
 * You can label PRs using `skip-tests` and `test-dependents` to fine-tune 
the checks executed by this PR.
 * Build and test logs are available in the summary page. **Only** [Apache 
Camel committers](https://camel.apache.org/community/team/#committers) have 
access to the summary.
 
 :warning: Be careful when sharing logs. Review their contents before 
sharing them publicly.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



Re: [PR] chore(components): specify custom span nesting in opentelemetry [camel]

2026-05-11 Thread via GitHub


squakez commented on PR #23120:
URL: https://github.com/apache/camel/pull/23120#issuecomment-4419870464

   @davsclaus @oscerd I need you to please have a look at this one. Please, 
advise if the documentation explaining the design constraint is wrong or should 
be reworded.
   
   Also, I wonder if this analysis is overlooking something. I understand that 
when we configure, for example, a bean to be called as an endpoint, then, the 
execution "converts" it as an event. Is there any possibility to have it as a 
regular processor and make the otel component to intercept it in the 
"InterceptStrategy" instead?
   
   Thanks!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]