code: private Metric createIntervalMetric(int currentDatapointIndex, Map<Long, Double> completeDatapoints,
                                          Long[] timestamps, long projectedIntervalStartTime) {
          Metric intervalMetric = new Metric(getResultScopeName(), getResultMetricName());
          Map<Long, Double> intervalMetricData = new HashMap<>();
  
          //Decrease intervalStartIndex until it's at the start of the interval
          int intervalStartIndex = currentDatapointIndex;
          while (intervalStartIndex >= 0 && timestamps[intervalStartIndex] >= projectedIntervalStartTime) {
              long tempTimestamp = timestamps[intervalStartIndex];
              //Fill in the intervalMetricData as we traverse backwards through the interval
              intervalMetricData.put(tempTimestamp, completeDatapoints.get(tempTimestamp));
              intervalStartIndex--;
          }
  
          intervalMetric.setDatapoints(intervalMetricData);
          return intervalMetric;
      }
docs: Creates an interval metric containing data points from a starting point
  (defined by the detection interval) to an ending point (currentDatapointIndex)
  
  @param currentDatapointIndex index of the current data point to create an interval for,
  will serve as the ending point of the interval
  @param completeDatapoints original metric data points
  @param timestamps sorted timestamps of the original metric
  @param projectedIntervalStartTime starting point of the interval
  @return Metric containing data points for the interval