Uploaded image for project: 'Flink'
  1. Flink
  2. FLINK-19901

Unable to exclude metrics variables for the last metrics reporter.

    XMLWordPrintableJSON

Details

    Description

      We discovered a bug that leads to the setting scope.variables.excludes being ignored for the very last metric reporter.

      Because reporterIndex was incremented before the length check, the last metrics reporter setting is overflowed back to 0.

      Interestingly, this bug does not trigger when there's only one metric reporter, because slot 0 is actually overwritten with that reporter's variables instead of being used to store all variables in that case.

      public abstract class AbstractMetricGroup<A extends AbstractMetricGroup<?>> implements MetricGroup {
      ...
      	public Map<String, String> getAllVariables(int reporterIndex, Set<String> excludedVariables) {
      		// offset cache location to account for general cache at position 0
      		reporterIndex += 1;
      		if (reporterIndex < 0 || reporterIndex >= logicalScopeStrings.length) {
      			reporterIndex = 0;
      		}
      		// if no variables are excluded (which is the default!) we re-use the general variables map to save space
      		return internalGetAllVariables(excludedVariables.isEmpty() ? 0 : reporterIndex, excludedVariables);
      	}
      
      ...
      

       Github link to the above code

      Attachments

        Issue Links

          Activity

            People

              chesnay Chesnay Schepler
              kien_truong Truong Duc Kien
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: