Skip to content

CAMEL-23312: Add SpanKind support to OpenTelemetry2 component#22653

Open
JiriOndrusek wants to merge 1 commit intoapache:mainfrom
JiriOndrusek:CAMEL-23312-add-spankind-to-telemetry-api-07
Open

CAMEL-23312: Add SpanKind support to OpenTelemetry2 component#22653
JiriOndrusek wants to merge 1 commit intoapache:mainfrom
JiriOndrusek:CAMEL-23312-add-spankind-to-telemetry-api-07

Conversation

@JiriOndrusek
Copy link
Copy Markdown
Contributor

fixes https://issues.apache.org/jira/browse/CAMEL-23312
superseeds #22612

Adds SpanKind parameter to the Camel telemetry API to enable proper span type classification (CLIENT, SERVER, PRODUCER, CONSUMER, INTERNAL) across different observability backends.

Changes

  • SpanDecorator API: Added getSpanKind(String operation) method to allow decorators to specify appropriate span kinds based on operation type
  • SpanLifecycleManager: Updated create() signature to accept spanKind parameter
  • Tracer: Modified to pass spanKind from decorator to lifecycle manager during span creation
  • OpenTelemetryTracer: Implemented spanKind support using OpenTelemetry's SpanKind enum
  • SpanDecorator implementations:
    • AbstractHttpSpanDecorator: Returns CLIENT for EVENT_SENT, SERVER for EVENT_RECEIVED
    • AbstractMessagingSpanDecorator: Returns PRODUCER for EVENT_SENT, CONSUMER for EVENT_RECEIVED
    • AbstractSpanDecorator: Returns INTERNAL as default

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 filed for the change (usually before you start working on it).

Apache Camel coding standards and style

  • I checked that each commit in the pull request has a meaningful subject line and body.
  • I have run mvn clean install -DskipTests locally from root folder and I have committed all auto-generated changes.

@github-actions
Copy link
Copy Markdown
Contributor

🌟 Thank you for your contribution to the Apache Camel project! 🌟
🤖 CI automation will test this PR automatically.

🐫 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 have access to the summary.

⚠️ Be careful when sharing logs. Review their contents before sharing them publicly.

@JiriOndrusek JiriOndrusek force-pushed the CAMEL-23312-add-spankind-to-telemetry-api-07 branch from 9af0c9d to e632ee2 Compare April 16, 2026 10:12
@JiriOndrusek JiriOndrusek requested a review from squakez April 16, 2026 10:12
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 16, 2026

🧪 CI tested the following changed modules:

  • components/camel-micrometer-observability
  • components/camel-opentelemetry2
  • components/camel-telemetry-dev
  • components/camel-telemetry
All tested modules (11 modules)
  • 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

⚙️ View full build and test results

Copy link
Copy Markdown
Contributor

@squakez squakez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work! A few notes to improve the overall readability of the code but the structure is good and compliant with the design.

Comment thread components/camel-telemetry/src/main/java/org/apache/camel/telemetry/Tracer.java Outdated
Comment thread components/camel-telemetry/src/main/java/org/apache/camel/telemetry/Tracer.java Outdated
@JiriOndrusek JiriOndrusek force-pushed the CAMEL-23312-add-spankind-to-telemetry-api-07 branch from e632ee2 to 948f06a Compare April 16, 2026 14:18
@davsclaus
Copy link
Copy Markdown
Contributor

LGTM

@@ -21,7 +21,7 @@
*/
public interface SpanLifecycleManager {

Span create(String spanName, Span parent, SpanContextPropagationExtractor extractor);
Span create(String spanName, String spanKind, Span parent, SpanContextPropagationExtractor extractor);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is not but just to double-check: this interface is not supposed ot be used outside of camel core?
If yes, would need to add a note in the upgrade guide

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, although I doubt anybody is implementing any custom component. However to be consistent we need to add a minor note as you suggest, but more important, we need to change the documentation in https://camel.apache.org/components/next/others/telemetry.html#_implementation_specific_abstraction to include the new param.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants