CAMEL-23225: Propagate OTel context in Spring Boot task executors#1730
CAMEL-23225: Propagate OTel context in Spring Boot task executors#1730
Conversation
Register an OTel context-propagating TaskDecorator bean in the camel-opentelemetry2-starter auto-configuration. This ensures Spring's ThreadPoolTaskExecutor (used by camel-platform-http-starter) propagates OpenTelemetry context to worker threads, preventing context leaks in async processing scenarios. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
squakez
left a comment
There was a problem hiding this comment.
Why is this change needed? see apache/camel#22190
This PR is wrapping the context around a thread. The context propagation for otel2 has nothing to deal with what it happened with otel1 component. IMO, we should discard this one.
|
@squakez Thanks for the feedback. After reading the design doc more carefully, I agree the core camel PR #22190 was wrong — wrapping all Camel-internal thread pools with For this Spring Boot starter PR, the question is more nuanced. The If So the real question is: should we remove the Happy to close this PR if the answer is header-only. Claude Code on behalf of Guillaume Nodet |
|
Threading logic belongs to Camel core, so, any problem with that, should be treated there. Likely camel-opentelemetry has some relation with that logic. However, camel-opentelemetry2 is designed not to have any relation with such, exactly with the scope of decoupling from those kind of potential problems we're suffering in camel-opentelemetry bound to thread context coupling. The storage of traces is, by design, propagated via exchanges headers. So, nothing is required, at least, according to this design. Also, that unit test has nothing to deal with Camel. It never starts a Camel application or a context, not sure what it was supposed to test of Camel framework. |
JIRA: CAMEL-23225
Summary
TaskDecoratorbean incamel-opentelemetry2-starterauto-configurationThreadPoolTaskExecutor(used bycamel-platform-http-starter) captures the current OTel context on the submitting thread and restores it on the worker thread@ConditionalOnMissingBeanallows users to provide their ownTaskDecoratorif neededFollow-up to apache/camel#22190 based on review feedback from @johnpoth.
Test plan
OtelContextPropagatingTaskDecoratorTestverifies theTaskDecoratorbean is auto-configuredClaude Code on behalf of Guillaume Nodet
🤖 Generated with Claude Code