code: protected void purgeObsoleteSamples(MetricConfig config, long now) {
          long expireAge = config.samples() * config.timeWindowMs();
          for (int i = 0; i < samples.size(); i++) {
              Sample sample = this.samples.get(i);
              if (now - sample.lastWindowMs >= expireAge) {
                  // The samples array is used as a circular list. The rank represents how many spots behind the current
                  // window is window #i at. The current sample is rank 0, the next older sample is 1 and so on until
                  // the oldest sample, which has a rank equal to samples.size() - 1.
                  int rank = current - i;
                  if (rank < 0) {
                      rank += samples.size();
                  }
                  // Here we reset the expired window to a time in the past that is offset proportionally to its rank.
                  sample.reset(now - rank * config.timeWindowMs());
              }
          }
      }
docs: Timeout any windows that have expired in the absence of any events