public Map<String, Double> getMetrics() {
    Map<String, Double> metrics = new HashMap<>();
    if (dagStatus == null) {
      return metrics;
    }
    Progress progress = dagStatus.getDAGProgress();
    metrics.put(TezSessionPoolManagerMetrics.TEZ_SESSION_METRIC_RUNNING_TASKS, (double) progress.getRunningTaskCount());
    // this logic for calculating pending tasks is inline with the one in TezProgressMonitor
    int pendingTasks = progress.getTotalTaskCount() - progress.getSucceededTaskCount() - progress.getRunningTaskCount();
    metrics.put(TezSessionPoolManagerMetrics.TEZ_SESSION_METRIC_PENDING_TASKS, (double) pendingTasks);
    return metrics;
  }
This method makes a best-effort attempt to retrieve data from the most recent dagStatus.
An alternative approach would be for Tez to expose a dedicated metrics endpoint for this purpose.
However, as long as TezJobMonitor continues polling the DAG states from the Tez AM, this method
will remain a reliable solution.

@return A map containing metrics for TezSessionPoolManagerMetrics.
ql/src/java/org/apache/hadoop/hive/ql/exec/tez/TezSessionState.java