[
https://issues.apache.org/jira/browse/CAMEL-27141?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Federico Mariani closed CAMEL-27141.
------------------------------------
Resolution: Won't Fix
Closing as the intended behaviour. Since CAMEL-23380 ({{design/tracing.adoc}},
"Removal of explicit camel-opentelemetry2 Scope wrapping to avoid leakage"),
Camel makes the OpenTelemetry context current only while a processor runs, so
the spans of a library called by an endpoint are children of the route span
rather than of the endpoint span. The trace, the timings and the metrics stay
complete; only that nesting is lost, which was accepted to avoid the leak.
A prototype showed the nesting can be restored by making the endpoint span
current until the processor call returns, on the same thread. The gain is
mostly cosmetic, and nobody has reported the flatter layout since 4.21, so it
is not worth changing the code path of CAMEL-23380.
_Claude Code on behalf of Croway_
> camel-opentelemetry2 - the spans of a library called by an endpoint are
> children of the route span instead of the endpoint span
> -------------------------------------------------------------------------------------------------------------------------------
>
> Key: CAMEL-27141
> URL: https://issues.apache.org/jira/browse/CAMEL-27141
> Project: Camel
> Issue Type: Improvement
> Components: camel-opentelemetry
> Reporter: Federico Mariani
> Priority: Major
>
> Since CAMEL-23380, {{camel-opentelemetry2}} does not make its spans current
> ({{OpenTelemetrySpanAdapter.makeCurrent}} does nothing), except around each
> processor, where {{TraceProcessorsOtelInterceptStrategy}} makes current the
> span on top of the exchange. For a {{to}}, that is the route span: the
> endpoint span is started afterwards, by the sending event, inside the
> processor.
> So the spans that an instrumented library records during the call (Spring AI
> or LangChain4j observations, an HTTP or JDBC client instrumented by the
> OpenTelemetry Java agent) become children of the route span, next to the
> endpoint span that wraps them instead of under it. A Spring Boot route
> calling {{spring-ai-chat}}, with Micrometer Tracing:
> {noformat}
> http post /chat/springai Spring MVC
> POST Camel consumer span
> spring-ai-chat Camel endpoint span
> chat <model> Spring AI, next to the endpoint span instead
> of under it
> POST HTTP calls to the model
> POST
> {noformat}
> This matters more since CAMEL-27131: when the AI framework already traces the
> model call, Camel defers to it and records no span of its own, so the
> framework span is the only record of the call.
> Proposal: make the endpoint span current for the duration of a synchronous
> producer call, opening and closing the scope on the same thread so that the
> leak fixed by CAMEL-23380 does not come back. For example the tracer could
> open the scope at the sending event and close it at the sent event when both
> run on the same thread, or a producer could open the scope of its endpoint
> span around its call with {{Span.openScope()}}, which CAMEL-27131 added to
> {{camel-telemetry}} for the GenAI spans. Asynchronous producers would keep
> today's behaviour.
> _Claude Code on behalf of Croway_
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)