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

John Poth commented on CAMEL-19469:
-----------------------------------

I'm also curious about the use case. The 
[OpenTelemetryTracingStrategy|https://github.com/apache/camel/blob/main/components/camel-opentelemetry/src/main/java/org/apache/camel/opentelemetry/OpenTelemetryTracingStrategy.java#L64]
 already creates a Span for Processors. It seems adding @WithSpan would just 
create another identical Span.

Unfortunately, naively putting,

{code:java}
// Some comments here
from("timer:tick?period=5s)
    .process("myProcessor");    

public class MyProcessor implements Processor {
    @WithSpan
    @Override
    public void process(Exchange exchange) {
        // Useful work here...
    }
}
{code}

In a Unit test does not reproduce the issue and the Context is correctly 
propagated.



> 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
(v8.20.10#820010)

Reply via email to