code: private void commitData()
        throws IOException {
      if (this.writer.isPresent()) {
        // Not to catch the exception this may throw so it gets propagated
        this.writer.get().commit();
      }
  
      try {
        if (GobblinMetrics.isEnabled(this.taskState.getWorkunit())) {
          // Update record-level and byte-level metrics after the writer commits
          updateRecordMetrics();
          updateByteMetrics();
        }
      } catch (IOException ioe) {
        // Trap the exception as failing to update metrics should not cause the task to fail
        this.logger.error("Failed to update byte-level metrics of task " + this.taskId);
      }
    }
docs: Commit task data.