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

Tracer doesn't continue spans for AbstractInternalSpanDecorator

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 3.20.2, 3.x, 4.0.0
    • 3.21.0, 4.0-M3, 4.0.0
    • camel-tracing
    • None
    • Unknown

    Description

      As discussed in the PR it seems that the `Tracer`component from `camel-tracing` is not continuing spans if a `AbstractInternalSpanDecorator` is being created. So for the following route

      from("direct://foo")
      				.log("hello")
      				.to("direct://bar")
      				.to("http://example.org");
      		from("direct://bar")
      				.log("hello")
      				.to("direct://micrometer")
      				.to("http://example.org");
      		from("direct://micrometer")
      				.setHeader(MicrometerConstants.HEADER_METRIC_NAME, constant("new.name"))
      				.setHeader(MicrometerConstants.HEADER_METRIC_TAGS, constant(Tags.of("dynamic-key", "dynamic-value")))
      				.to("micrometer:counter:name.not.used?tags=key=value")
      				.to("direct://baz");
      		from("direct://baz")
      				.log("hello")
      				.to("bean:com.example.cameldemo.MyBean")
      				.to("exec:wc?args=--words /usr/share/dict/words")
      				.process(exchange -> {
      					// Use the Camel Exec String type converter to convert the ExecResult to String
      					// In this case, the stdout is considered as output
      					String wordCountOutput = exchange.getIn().getBody(String.class);
      					// do something with the word count
      					System.out.println(wordCountOutput);
      				})
      				.to("file:///tmp/camel-outputdir?flatten=true")
      				.to("http://example.org");
      

      you will get multiple traces since the `direct` components are not linked together (they are treated as a start of a new trace).

      I think we agreed that for this route example, multiple routes are linked together but all in all they form a single trace. So if `org.apache.camel.tracing.Tracer.TracingEventNotifier#shouldExclude` would be changed from

      private boolean shouldExclude(SpanDecorator sd, Exchange exchange, Endpoint endpoint) {
                  return sd instanceof AbstractInternalSpanDecorator || !sd.newSpan()
                          || isExcluded(exchange, endpoint);
              }
      

      to

      private boolean shouldExclude(SpanDecorator sd, Exchange exchange, Endpoint endpoint) {
                  return !sd.newSpan()
                          || isExcluded(exchange, endpoint);
              }
      

      then the span parent-child relationship gets maintained the way it should

      Attachments

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            marcingrzejszczak Marcin Grzejszczak
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment