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

Wrong statistics for subroutes

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.15.2
    • Fix Version/s: 2.16.0, 2.15.4
    • Component/s: camel-metrics
    • Labels:
      None
    • Estimated Complexity:
      Unknown

      Description

      Some statistics seem to be wrong for subroutes.

      MetricsStatistics.onExchangeDone method is called several times for a same exchange: first by the subroute and then by its parent route.

      The problem is that context.stop() is called several times so counters is greater than 1 for the subroute instead of one.

      A solution could be to reset the context into the exchange as soon as the stop method has been called:

      MetricsRoutePolicy.java
      private static final class MetricsStatistics {
              private final Timer responses;
      
              private MetricsStatistics(Timer responses) {
                  this.responses = responses;
              }
      
              public void onExchangeBegin(Exchange exchange) {
                  Timer.Context context = responses.time();
                  exchange.setProperty("MetricsRoutePolicy", context);
              }
      
              public void onExchangeDone(Exchange exchange) {
                  Timer.Context context = exchange.getProperty("MetricsRoutePolicy", Timer.Context.class);
                  if (context != null) {
                      context.stop();
                      // BUGFIX: reset to null so that context.stop() cannot be called
                      // more than once.
                      exchange.setProperty("MetricsRoutePolicy", null);
      
                  }
              }
          }
      

        Attachments

          Activity

            People

            • Assignee:
              davsclaus Claus Ibsen
              Reporter:
              vlebreil Vincent Lebreil
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: