code: @VisibleForTesting
    void countersToMetrics(GobblinMetrics metrics) throws IOException {
      Optional<Counters> counters = Optional.fromNullable(this.job.getCounters());
  
      if (counters.isPresent()) {
        // Write job-level counters
        CounterGroup jobCounterGroup = counters.get().getGroup(MetricGroup.JOB.name());
        for (Counter jobCounter : jobCounterGroup) {
          metrics.getCounter(jobCounter.getName()).inc(jobCounter.getValue());
        }
  
        // Write task-level counters
        CounterGroup taskCounterGroup = counters.get().getGroup(MetricGroup.TASK.name());
        for (Counter taskCounter : taskCounterGroup) {
          metrics.getCounter(taskCounter.getName()).inc(taskCounter.getValue());
        }
      }
    }
docs: Create a {@link org.apache.gobblin.metrics.GobblinMetrics} instance for this job run from the Hadoop counters.