public void reportStageEnd(String stageName, Status status, long lastReplId,
      SnapshotUtils.ReplSnapshotCount replSnapshotCount, ReplStatsTracker replStatsTracker) throws SemanticException {
    unRegisterMBeanSafe();
    if (isEnabled) {
      LOG.debug("Stage ended {}, {}, {}", stageName, status, lastReplId );
      Progress progress = replicationMetric.getProgress();
      Stage stage = progress.getStageByName(stageName);
      if(stage == null){
        stage = new Stage(stageName, status, -1L);
      }
      stage.setStatus(status);
      stage.setEndTime(getCurrentTimeInMillis());
      stage.setReplSnapshotsCount(replSnapshotCount);
      if (replStatsTracker != null && !(replStatsTracker instanceof NoOpReplStatsTracker)) {
        String replStatString = replStatsTracker.toString();
        LOG.info("Replication Statistics are: {}", replStatString);
        stage.setReplStats(replStatString);
      }
      progress.addStage(stage);
      replicationMetric.setProgress(progress);
      Metadata metadata = replicationMetric.getMetadata();
      metadata.setLastReplId(lastReplId);
      metadata.setReplicatedDBSizeInKB(sizeOfDataReplicatedInKB.get());
      replicationMetric.setMetadata(metadata);
      metricCollector.addMetric(replicationMetric);
      if (Status.FAILED == status || Status.FAILED_ADMIN == status) {
        reportEnd(status);
      }
    }
  }
Abstract class for Replication Metric Collection.
ql/src/java/org/apache/hadoop/hive/ql/parse/repl/metric/ReplicationMetricCollector.java