You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by "JiriOndrusek (via GitHub)" <gi...@apache.org> on 2026/04/14 16:39:58 UTC
[PR] CAMEL-23312: Add SpanKind support to OpenTelemetry2 component [camel]
JiriOndrusek opened a new pull request, #22612:
URL: https://github.com/apache/camel/pull/22612
fixes https://issues.apache.org/jira/browse/CAMEL-23312
superseeds https://github.com/apache/camel/pull/22577
- Adds SpanKind support to the OpenTelemetry2 component to enable proper distributed tracing
semantics
- Implements SpanKind determination through the SpanDecorator API with HTTP components using
CLIENT/SERVER and messaging components using PRODUCER/CONSUMER
- Includes comprehensive test coverage with mock HTTP and Kafka components to verify SpanKind
behavior and decorator property inheritance
# Description
<!--
- Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
-->
# Target
- [ ] I checked that the commit is targeting the correct branch (Camel 4 uses the `main` branch)
# Tracking
- [ ] If this is a large change, bug fix, or code improvement, I checked there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for the change (usually before you start working on it).
<!--
# *Note*: trivial changes like, typos, minor documentation fixes and other small items do not require a JIRA issue. In this case your pull request should address just this issue, without pulling in other changes.
-->
# Apache Camel coding standards and style
- [ ] I checked that each commit in the pull request has a meaningful subject line and body.
<!--
If you're unsure, you can format the pull request title like `[CAMEL-XXX] Fixes bug in camel-file component`, where you replace `CAMEL-XXX` with the appropriate JIRA issue.
-->
- [ ] I have run `mvn clean install -DskipTests` locally from root folder and I have committed all auto-generated changes.
<!--
You can run the aforementioned command in your module so that the build auto-formats your code. This will also be verified as part of the checks and your PR may be rejected if if there are uncommited changes after running `mvn clean install -DskipTests`.
You can learn more about the contribution guidelines at https://github.com/apache/camel/blob/main/CONTRIBUTING.md
-->
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-23312: Add SpanKind support to OpenTelemetry2 component [camel]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #22612:
URL: https://github.com/apache/camel/pull/22612#issuecomment-4246278903
<!-- ci-tested-modules -->
:test_tube: **CI tested the following changed modules:**
- `components/camel-opentelemetry2`
- `components/camel-telemetry`
<details><summary>All tested modules (11 modules)</summary>
- Camel :: Common Telemetry
- Camel :: JBang :: MCP
- Camel :: JBang :: Plugin :: Route Parser
- 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
</details>
---
:gear: [View full build and test results](https://github.com/apache/camel/actions/runs/24411263576)
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-23312: Add SpanKind support to OpenTelemetry2 component [camel]
Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus commented on code in PR #22612:
URL: https://github.com/apache/camel/pull/22612#discussion_r3088447546
##########
components/camel-opentelemetry2/src/main/java/org/apache/camel/opentelemetry2/OpenTelemetrySpanAdapter.java:
##########
@@ -16,38 +16,82 @@
*/
package org.apache.camel.opentelemetry2;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import io.opentelemetry.api.baggage.Baggage;
import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.api.trace.Span;
+import io.opentelemetry.api.trace.SpanBuilder;
+import io.opentelemetry.api.trace.SpanKind;
import io.opentelemetry.api.trace.StatusCode;
import io.opentelemetry.context.Scope;
+import org.apache.camel.telemetry.Op;
import org.apache.camel.telemetry.TagConstants;
public class OpenTelemetrySpanAdapter implements org.apache.camel.telemetry.Span {
private static final String DEFAULT_EVENT_NAME = "log";
static final String BAGGAGE_CAMEL_FLAG = "camelScope";
- private final Span otelSpan;
+ private Span otelSpan;
private final Baggage baggage;
private Scope scope;
private Scope baggageScope;
- protected OpenTelemetrySpanAdapter(Span otelSpan, Baggage baggage) {
- this.otelSpan = otelSpan;
- // We store an important flag in the baggage in order to verify if the
- // root span was generated internally or from a third party dependency.
- this.baggage = baggage.toBuilder().put(BAGGAGE_CAMEL_FLAG, "true").build();
+ // For deferred span creation
+ private SpanBuilder spanBuilder;
+ private final Map<String, String> pendingTags = new HashMap<>();
Review Comment:
should these map/list be concurrent variants in case multi threads calls at the same time
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-23312: Add SpanKind support to OpenTelemetry2 component [camel]
Posted by "JiriOndrusek (via GitHub)" <gi...@apache.org>.
JiriOndrusek commented on PR #22612:
URL: https://github.com/apache/camel/pull/22612#issuecomment-4252397154
Hi @squakez,
I've tried to follow your hints.
1 - I agree with avoiding Op in decorators
2 - I added `span.kind()` into Span and started from it.
Unfortunately the `io.opentelemetry.api.trace.Span` needs to know its spanKind before starting. I had to deffer the start of the span into the `makeCurrent` method to be able to detect the spanKind. I put the detection into `OpenTelemetrySpanAdapter` and kept it completely self contained. (I used other tags for it) So I actually did not need the `span.kind()` anymore. What do you think? from my PoV the change is quite small and isolated to opentelemetry2. No API is changed. Test suite is the same as in previous attempts.
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-23312: Add SpanKind support to OpenTelemetry2 component [camel]
Posted by "JiriOndrusek (via GitHub)" <gi...@apache.org>.
JiriOndrusek commented on PR #22612:
URL: https://github.com/apache/camel/pull/22612#issuecomment-4258970538
superseded by https://github.com/apache/camel/pull/22653
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-23312: Add SpanKind support to OpenTelemetry2 component [camel]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #22612:
URL: https://github.com/apache/camel/pull/22612#issuecomment-4246141252
: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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-23312: Add SpanKind support to OpenTelemetry2 component [camel]
Posted by "JiriOndrusek (via GitHub)" <gi...@apache.org>.
JiriOndrusek commented on code in PR #22612:
URL: https://github.com/apache/camel/pull/22612#discussion_r3092204736
##########
components/camel-opentelemetry2/src/main/java/org/apache/camel/opentelemetry2/OpenTelemetrySpanAdapter.java:
##########
@@ -16,38 +16,82 @@
*/
package org.apache.camel.opentelemetry2;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import io.opentelemetry.api.baggage.Baggage;
import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.api.trace.Span;
+import io.opentelemetry.api.trace.SpanBuilder;
+import io.opentelemetry.api.trace.SpanKind;
import io.opentelemetry.api.trace.StatusCode;
import io.opentelemetry.context.Scope;
+import org.apache.camel.telemetry.Op;
import org.apache.camel.telemetry.TagConstants;
public class OpenTelemetrySpanAdapter implements org.apache.camel.telemetry.Span {
private static final String DEFAULT_EVENT_NAME = "log";
static final String BAGGAGE_CAMEL_FLAG = "camelScope";
- private final Span otelSpan;
+ private Span otelSpan;
private final Baggage baggage;
private Scope scope;
private Scope baggageScope;
- protected OpenTelemetrySpanAdapter(Span otelSpan, Baggage baggage) {
- this.otelSpan = otelSpan;
- // We store an important flag in the baggage in order to verify if the
- // root span was generated internally or from a third party dependency.
- this.baggage = baggage.toBuilder().put(BAGGAGE_CAMEL_FLAG, "true").build();
+ // For deferred span creation
+ private SpanBuilder spanBuilder;
+ private final Map<String, String> pendingTags = new HashMap<>();
Review Comment:
I discussed the changes with @squakez and I'll open the new PR which does not need all this code for defferring span creation
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-23312: Add SpanKind support to OpenTelemetry2 component [camel]
Posted by "JiriOndrusek (via GitHub)" <gi...@apache.org>.
JiriOndrusek commented on PR #22612:
URL: https://github.com/apache/camel/pull/22612#issuecomment-4245612816
@squakez here is the refactored PR, I force pushed a change to my branch, so i could not reopen the ticket (I didn't know about this limitation). Therefore this is the new PR.
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-23312: Add SpanKind support to OpenTelemetry2 component [camel]
Posted by "squakez (via GitHub)" <gi...@apache.org>.
squakez commented on PR #22612:
URL: https://github.com/apache/camel/pull/22612#issuecomment-4250026399
Alternatively we could even think to expose the "kind" in the Span (ie, `span.kind()`), just for the sake to avoid adding the Op in the decorator methods. In this way all you need is self contained and indeed you can have as much as Kind types as you need in the SpanAdapter which is implemented at a concrete component level. Yeah, I think this is the best way to handle to minimize the impact and be compliant with the design.
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CAMEL-23312: Add SpanKind support to OpenTelemetry2 component [camel]
Posted by "JiriOndrusek (via GitHub)" <gi...@apache.org>.
JiriOndrusek closed pull request #22612: CAMEL-23312: Add SpanKind support to OpenTelemetry2 component
URL: https://github.com/apache/camel/pull/22612
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org