Skip to content

Camel 23283 micrometer span scope#22410

Open
beskow wants to merge 3 commits intoapache:mainfrom
beskow:CAMEL-23283-micrometer-span-scope
Open

Camel 23283 micrometer span scope#22410
beskow wants to merge 3 commits intoapache:mainfrom
beskow:CAMEL-23283-micrometer-span-scope

Conversation

@beskow
Copy link
Copy Markdown
Contributor

@beskow beskow commented Apr 2, 2026

Description

Pull request to correct behavior reported in https://issues.apache.org/jira/browse/CAMEL-23283:

When using camel-observability or camel-micrometer-observability, traces and spans are correctly created and exported for routes triggered by other, tracing-aware framework components (e.g. http). If a route is triggered by a jms message, no trace or span is exported however.

This seems to be caused by missing scope management: MicrometerObservabilitySpanAdapter::activate() only calls span.start() but doesn't put the
span into the tracer's thread-local scope. This means tracer.currentSpan() returns null during route execution, hence the span is invisible to downstream instrumentation that relies on tracer.currentSpan() to find a parent span.

The first commit adds a test to highlight the problem.
The second commit corrects the root cause of the problem, but cause side effects for other tests (the async test cases) which leaks trace information between test execution.
The third commit prevents leaked trace information from being propagated.

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.

@Croway Croway requested a review from squakez April 2, 2026 15:11
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 2, 2026

🌟 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 build-all, build-dependents, 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.

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.

2 participants