[ 
https://issues.apache.org/jira/browse/CAMEL-19469?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18151642#comment-18151642
 ] 

Claus Ibsen commented on CAMEL-19469:
-------------------------------------

Since CAMEL-20643 (4.4.4 / 4.6.0) the OpenTelemetry tracing strategy makes the 
context current for processors, so
spans created with `@WithSpan` inside a processor or bean nest under the Camel 
span. camel-opentelemetry is now
deprecated in favour of camel-opentelemetry2, which documents this ("bean with 
@WithSpan annotation for custom span
nesting") and tests it in `SpanBeanTest`. Closing; please reopen with a 
reproducer against camel-opentelemetry2 if it
still happens.

_Claude Code on behalf of davsclaus_

> camel-opentelemetry: Context not propagated correctly when tracing bean or 
> processor invocations with @WithSpan
> ---------------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-19469
>                 URL: https://issues.apache.org/jira/browse/CAMEL-19469
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-opentelemetry
>    Affects Versions: 3.20.5, 4.0-M3
>            Reporter: James Netherton
>            Priority: Minor
>
> OpenTelemetry enables you to trace arbitrary method invocations by tagging 
> them with the @WithSpan annotation:
> https://opentelemetry.io/docs/instrumentation/java/automatic/annotations/#creating-spans-around-methods-with-withspan
> For some scenarios, the tracing context does not seem to get propagated and 
> the resulting spans end up being disassociated. For example:
> {code}
> from("timer:tick?period=5s)
>     .process("myProcessor");    
> {code}
> {code}
> public class MyProcessor implements Processor {
>     @WithSpan
>     @Override
>     public void process(Exchange exchange) {
>         // Useful work here...
>     }
> }
> {code}
> This results in 2 spans. One for timer:tick & another for MyProcessor. The 
> problem is that the parent span for MyProcessor is not set, so they appear as 
> 2 distinct traces.
> There is a workaround where you can configure the route like this and the 
> span hierarchy ends up being correct:
> {code}
> from("timer:tick?period=5s")
>     .to("direct:start");
> from("direct:start")
>     .process("myProcessor");
> {code}
> There's some more background in the original issue reported on Camel Quarkus:
> https://github.com/apache/camel-quarkus/issues/4981
> There's also a reproducer project here:
> https://github.com/jamesnetherton/camel-opentelemetry-demo



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to