public static void updateMetricsFromWorker(String dbName, String tableName,
      String partitionName, CompactionType type, int preWorkerActiveDeltaCount, int preWorkerDeleteDeltaCount,
      Configuration conf, IMetaStoreClient client) {
    if (!(MetastoreConf.getBoolVar(conf, MetastoreConf.ConfVars.METRICS_ENABLED) &&
        MetastoreConf.getBoolVar(conf, MetastoreConf.ConfVars.METASTORE_ACIDMETRICS_THREAD_ON))) {
      LOG.debug("Acid metric collection is not enabled. To turn it on, \"metastore.acidmetrics.thread.on\" and "
          + "\"metastore.metrics.enabled\" must be set to true and HS2/HMS restarted.");
      return;
    }
    LOG.debug("Updating delta file metrics from worker");
    int deltasThreshold =
        MetastoreConf.getIntVar(conf, MetastoreConf.ConfVars.METASTORE_DELTAMETRICS_DELTA_NUM_THRESHOLD);
    int obsoleteDeltasThreshold =
        MetastoreConf.getIntVar(conf, MetastoreConf.ConfVars.METASTORE_DELTAMETRICS_OBSOLETE_DELTA_NUM_THRESHOLD);
    try {
      // we have an instance of the AcidDirectory before the compaction worker was started
      // from this we can get how many delta directories existed
      // the previously active delta directories are now moved to obsolete
      updateDeltaMetrics(dbName, tableName, partitionName, CompactionMetricsMetricType.NUM_OBSOLETE_DELTAS,
          preWorkerActiveDeltaCount, obsoleteDeltasThreshold, client);

      // We don't know the size of the newly create delta directories, that would require a fresh AcidDirectory
      // Clear the small delta num counter from the cache for this key
      removeDeltaMetrics(dbName, tableName, partitionName, CompactionMetricsMetricType.NUM_SMALL_DELTAS, client);

      // The new number of active delta dirs are either 0, 1 or 2.
      // If we ran MAJOR compaction, no new delta is created, just base dir
      // If we ran MINOR compaction, we can have 1 or 2 new delta dirs, depending on whether we had deltas or
      // delete deltas.
      if (type == CompactionType.MAJOR) {
        removeDeltaMetrics(dbName, tableName, partitionName, CompactionMetricsMetricType.NUM_DELTAS, client);
      } else {
        int numNewDeltas = 0;
        // check whether we had deltas
        if (preWorkerDeleteDeltaCount > 0) {
          numNewDeltas++;
        }

        // if the size of the current dirs is bigger than the size of delete deltas, it means we have active deltas
        if (preWorkerActiveDeltaCount > preWorkerDeleteDeltaCount) {
          numNewDeltas++;
        }

        // recalculate the delta count
        updateDeltaMetrics(dbName, tableName, partitionName, CompactionMetricsMetricType.NUM_DELTAS, numNewDeltas,
            deltasThreshold, client);
      }

      LOG.debug("Finished updating delta file metrics from worker.\n deltasThreshold = {}, "
              + "obsoleteDeltasThreshold = {}, numObsoleteDeltas = {}", deltasThreshold, obsoleteDeltasThreshold,
          preWorkerActiveDeltaCount);

    } catch (Throwable t) {
      LOG.warn("Unknown throwable caught while updating delta metrics. Metrics will not be updated.", t);
    }
  }
Collect and publish ACID and compaction related metrics.
Everything should be behind 2 feature flags: {@link MetastoreConf.ConfVars#METRICS_ENABLED} and
{@link MetastoreConf.ConfVars#METASTORE_ACIDMETRICS_THREAD_ON}.
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/metrics/AcidMetricService.java