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

camel-micrometer - Micrometer observation component losses spans during tracing

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Information Provided
    • 4.4.0
    • 4.x
    • camel-micrometer
    • None
    • Unknown

    Description

      I've got an issue in my project related with Camel Observation within routes. Most of the time, during request processing previous spans are losing, so multiple traces can be created for one request. Also, for unknown reasons some of the spans that were created in current request, can join previous trace where spans were missed.

      Workflow:

      // 1. Spring controller producing the event to SEDA dictSync
      producerTemplate.send(SEDA_DICT_SYNC_START.getUri(), exchange ->
          exchange.getIn().setBody(objectMapper.writeValueAsString(entities)));
      
      // 2. Event-driven consumer consumes the event from SEDA dictSync and processes it in dictSyncStartProcessor
      from(SEDA_DICT_SYNC_START)
          .routeId("DictSyncStart")
          .unmarshal().json(JsonLibrary.Jackson)
          .onException(Exception.class).handled(true)
              .process(exchange -> handleException((String) exchange.getIn().getBody(ArrayList.class).get(0), exchange))
          .end()
          .process(dictSyncStartProcessor);
      
      // 3. dictSyncStartProcessor processes the event and send another to SEDA dictSyncSplit
      producerTemplate.send(SEDA_DICT_SYNC_SPLIT.getUri(), exchange -> {
          Message message = exchange.getIn();
      
          entitySync.setUpdateDatetime(updateDatetime);
          message.setHeader("destination", destination.name());
          message.setHeader("entity", objectMapper.writeValueAsString(entitySync));
          message.setHeader("messageId", messageId);
          message.setBody(data);
      });
      
      // 4. dictSyncSplit consumes event, split its body, aggregate splitted records and send aggregated record to kafka
      from(SEDA_DICT_SYNC_SPLIT)
          .routeId("DictSyncSplit")
          .onException(Exception.class).handled(true).useOriginalMessage()
              .process(exchange -> {
                  var entitySync = objectMapper.readValue(exchange.getIn().getHeader("entity", String.class), EntitySync.class);
                  handleException(entitySync.getEntity(), exchange);
              })
          .end()
          .split(body())
          .aggregate(header("messageId"), aggregationStrategy)
              .completionSize(20)
              .completionTimeout(1000L)
          .marshal().json(JsonLibrary.Jackson)
          .to(kafka(DICTIONARY_SYNC_TOPIC));
      
      // 5. dictionarySync route consumes event from kafka and send another to proccesedEntitySync
      producerTemplate.send(kafka(PROCESSED_ENTITY_SYNC_TOPIC).getUri(), ex ->
          ex.getIn().setBody(objectMapper.writeValueAsString(entitySync)));

       

      First case

      Actual unexpected results:

      • dictSyncSplit route observations are missing (but will be associated during next request)
      • processedEntitySync is separated into another trace

      After invoking this request once again, new spans were associated with first request:

       

      Second case

      Actual unexpected results:

      • dictSyncSplit is separated into another trace
      • processedEntitySync is separated into another trace

       

      Observation dependencies:

      implementation 'org.springframework.boot:spring-boot-starter-aop'
      implementation 'io.micrometer:micrometer-tracing-bridge-otel'
      implementation 'io.opentelemetry:opentelemetry-exporter-zipkin'
      implementation 'org.apache.camel.springboot:camel-observation-starter:4.4.0'

      Spring boot version: 3.2.2

      Attachments

        1. image-2024-03-22-16-51-48-525.png
          23 kB
          Kutorkin Artyom
        2. image-2024-03-22-16-46-21-015.png
          76 kB
          Kutorkin Artyom
        3. image-2024-03-22-16-34-54-659.png
          28 kB
          Kutorkin Artyom
        4. image-2024-03-22-16-34-11-487.png
          32 kB
          Kutorkin Artyom

        Issue Links

          Activity

            People

              Unassigned Unassigned
              a1pha1337 Kutorkin Artyom
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: