code: public void endStage() {
      if (this.currentStage != null) {
        long time = System.currentTimeMillis() - this.currentStageStart;
        this.timings.add(new Stage(this.currentStage, time));
        if (reportAsMetrics && submitter.getMetricContext().isPresent()) {
          String timerName = submitter.getNamespace() + "." + name + "." + this.currentStage;
          submitter.getMetricContext().get().timer(timerName).update(time, TimeUnit.MILLISECONDS);
        }
      }
      this.currentStage = null;
    }
docs: End the previous stage and record the time spent in that stage.