void collectMetrics() {
    List<TezSessionState> sessions = poolManager.getSessions();
    LOG.debug("Updating metrics, session count: {}", sessions.size());

    if (sessions.isEmpty()) {
      // no active session, don't mess with the rest
      clearMetrics();
      return;
    }

    AtomicDouble currentRunningTasksCount = new AtomicDouble();
    AtomicDouble currentPendingTasksCount = new AtomicDouble();
    List<Future<?>> collectTasks = new ArrayList<>();

    // run on maximum 10 threads
    ExecutorService collectorExecutor = Executors.newFixedThreadPool(Math.min(sessions.size(), 10),
        new ThreadFactoryBuilder().setNameFormat("TezSessionPoolManagerMetrics collector thread - #%d").build());
    long start = Time.monotonicNow();

    for (TezSessionState session : sessions) {
      collectTasks.add(CompletableFuture.runAsync(() -> {
        Map<String, Double> metrics = session.getMetrics();
        LOG.debug("Achieved metrics from Tez session ({}): {}", session.getSessionId(), metrics);

        currentRunningTasksCount.addAndGet(metrics.getOrDefault(runningTasksCount.name, 0.0));
        currentPendingTasksCount.addAndGet(metrics.getOrDefault(pendingTasksCount.name, 0.0));
      }, collectorExecutor));
    }

    waitForTasksToFinish(collectTasks, collectorExecutor);
    long elapsed = Time.monotonicNow() - start;

    refreshMetrics(currentRunningTasksCount, currentPendingTasksCount);

    LOG.debug("Collected metrics from {} sessions (in {}ms): {}", sessions.size(), elapsed, toMetricsString());
  }
TezSessionPoolManagerMetrics collects, aggregates and exposes data from Tez sessions to Hive's own MetricsFactory.
This is independent of the Tez DagClient which is active only while running DAGs.
ql/src/java/org/apache/hadoop/hive/ql/exec/tez/TezSessionPoolManagerMetrics.java