public TezSessionPoolManagerMetrics start(HiveConf conf) {
    if (metrics == null) {
      LOG.warn(
          "Metrics are not enabled, cannot start TezSessionPoolManagerMetrics (check {})",
          HiveConf.ConfVars.HIVE_SERVER2_METRICS_ENABLED.varname);
      return this;
    }
    this.mainExecutor = Executors.newSingleThreadScheduledExecutor(
        new ThreadFactoryBuilder().setNameFormat("TezSessionPoolManagerMetrics worker thread").setDaemon(true).build());
    long collectIntervalSeconds = HiveConf.getTimeVar(conf,
        HiveConf.ConfVars.HIVE_SERVER2_TEZ_SESSIONS_METRICS_COLLECTION_INTERVAL, TimeUnit.SECONDS);
    mainExecutor.scheduleAtFixedRate(this::collectMetrics, 0, collectIntervalSeconds, TimeUnit.SECONDS);
    LOG.info("Starting TezSessionPoolManagerMetrics, collection interval: {}s", collectIntervalSeconds);

    runningTasksCount.createGauge(metrics);
    pendingTasksCount.createGauge(metrics);
    taskBacklogRatio.createGauge(metrics);
    for (TaskBacklogRatioMetric m : taskBacklogRatioDurations) {
      m.createGauge(metrics);
    }
    clearMetrics(); //initial empty values for gauges
    return this;
  }
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