@Override
  public void start() {
    // Create metrics directory if it is not present
    if (!metricsDir.toFile().exists()) {
      LOGGER.warn("Metrics directory {} does not exist, creating one", metricsDir);
      try {
        // createDirectories creates all nonexistent parent directories
        Files.createDirectories(metricsDir, DIR_ATTRS);
      } catch (IOException e) {
        LOGGER.error("Failed to create directory {}: {}", metricsDir, e.getMessage());
        return;
      }
    }

    executorService = Executors.newScheduledThreadPool(1,
        new ThreadFactoryBuilder().setNameFormat(JSON_REPORTER_THREAD_NAME).build());
    executorService.scheduleWithFixedDelay(this,0, interval, TimeUnit.MILLISECONDS);
  }
A metrics reporter for CodahaleMetrics that dumps metrics periodically into
a file in JSON format. Only files on local filesystems are supported.
standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/common/metrics/metrics2/JsonFileMetricsReporter.java