Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-19469

camel-opentelemetry: Context not propagated correctly when tracing bean or processor invocations with @WithSpan

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 3.20.5, 4.0-M3
    • None
    • camel-opentelemetry
    • None
    • Unknown

    Description

      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:

      from("timer:tick?period=5s)
          .process("myProcessor");    
      
      public class MyProcessor implements Processor {
          @WithSpan
          @Override
          public void process(Exchange exchange) {
              // Useful work here...
          }
      }
      

      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:

      from("timer:tick?period=5s")
          .to("direct:start");
      
      from("direct:start")
          .process("myProcessor");
      

      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

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              jamesnetherton James Netherton
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated: