private boolean writeTailMetadata(boolean finished) {
    if (!taskDefinition.getExecutorData().getLoggingTag().isPresent()) {
      if (!finished) {
        log.warn("Not writing logging metadata because logging tag is absent");
      }
      return true;
    }

    final TailMetadata tailMetadata =
        new TailMetadata(
            taskDefinition.getServiceLogOut(),
            taskDefinition.getExecutorData().getLoggingTag().get(),
            taskDefinition.getExecutorData().getLoggingExtraFields(),
            finished);
    final Path path =
        TailMetadata.getTailMetadataPath(
            configuration.getLogMetadataDirectory(),
            configuration.getLogMetadataSuffix(),
            tailMetadata);

    return jsonObjectFileHelper.writeObject(tailMetadata, path, log);
  }
  private boolean writeS3MetadataFile(boolean finished) {
    Path logrotateDirectory =
        taskDefinition
            .getServiceLogOutPath()
            .getParent()
            .resolve(configuration.getLogrotateToDirectory());

    S3UploadMetadata s3UploadMetadata =
        new S3UploadMetadata(
            logrotateDirectory.toString(),
            getS3Glob(),
            configuration.getS3Bucket(),
            getS3KeyPattern(),
            finished);

    String s3UploadMetadatafilename =
        String.format("%s%s", taskDefinition.getTaskId(), configuration.getS3MetadataSuffix());

    Path s3UploadMetadataPath =
        configuration.getS3MetadataDirectory().resolve(s3UploadMetadatafilename);

    return jsonObjectFileHelper.writeObject(s3UploadMetadata, s3UploadMetadataPath, log);
  }