Skip to content

Add SpanKind parameter to telemetry API to support proper span type#22577

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

Add SpanKind parameter to telemetry API to support proper span type#22577
JiriOndrusek wants to merge 1 commit intoapache:mainfrom
JiriOndrusek:CAMEL-23312-add-spankind-to-telemetry-api

Conversation

@JiriOndrusek
Copy link
Copy Markdown
Contributor

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

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

Changes:

  • Introduces org.apache.camel.telemetry.SpanKind enum
  • Updates SpanLifecycleManager.create() signature to accept span kind
  • Implements span kind mapping in tracer implementations:
    • OpenTelemetry2: Maps to native io.opentelemetry.api.trace.SpanKind
    • Micrometer: Accepts parameter for API compatibility (kind determined by Observation context) without using it
    • TelemetryDev: Stores as span tag
  • Extends SpanDecorator and decorator implementations to provide span kind information
  • Migrates test code from Thread.sleep() to Awaitility for more reliable async testing

Impact: Enables proper span classification in distributed traces, improving observability for
messaging and HTTP components.

Description

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.

* <ul>
* <li>CLIENT - The span covers a client-side call to a remote service</li>
* <li>SERVER - The span covers server-side handling of a remote request</li>
* <li>PRODUCER - The span covers the production of a message to a remote broker/queue</li>
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 dont think this is limited to a remote broker/queue, it can be any kind of remote networking, even a HTTP REST call and so on.

@davsclaus
Copy link
Copy Markdown
Contributor

There is some API changes it would be nice to add this in the 4.20 upgrade guide doc.

@davsclaus davsclaus requested a review from squakez April 13, 2026 08:41
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.

I will have a thoroughly look asap. However, in the while just consider that the "spanKind" concept is an opentelemetry concept only and not necessarily supported by any other telemetry components. Ideally this feature should be developed at subcomponent level only and we need to evaluate if any generic "extension point" is really required on the abstract telemetry component.

I will give you more details shortly.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 13, 2026

🧪 CI tested the following changed modules:

  • components/camel-micrometer-observability
  • components/camel-opentelemetry2
  • components/camel-telemetry-dev
  • components/camel-telemetry
  • docs
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

@JiriOndrusek JiriOndrusek force-pushed the CAMEL-23312-add-spankind-to-telemetry-api branch from 84146e8 to 8b0b9b5 Compare April 13, 2026 11:10
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.

Thanks for the work but I think what you're trying to achieve is already covered by the presence of the SpanDecorator, whose goal is exactly to include any additional information to the Span before or after the trace is generated (via methods public void beforeTracingEvent(Span span, Exchange exchange, Endpoint endpoint) and public void afterTracingEvent(Span span, Exchange exchange)).

I think that the kind can be generated and set on the span directly in each decorator, which would be also cleaner from an API point of view.

@JiriOndrusek
Copy link
Copy Markdown
Contributor Author

Superseded by #22610

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.

3 participants