public static Map commonTags()

in spectator-nflx-tagging/src/main/java/com/netflix/spectator/nflx/tagging/NetflixTagging.java [98:144]


  public static Map<String, String> commonTags(Function<String, String> getenv) {
    // Note, these extract from the environment directly rather than use the helper
    // methods that access the reference config. This is done because the helpers
    // assign default values to many of the entries which can be convenient for testing,
    // but are not appropriate for inclusion with tags.
    Map<String, String> tags = new HashMap<>();

    // Generic infrastructure
    putIfNotEmptyOrNull(getenv, tags, "nf.account",
        "NETFLIX_ACCOUNT_ID",
        "EC2_OWNER_ID");
    putIfNotEmptyOrNull(getenv, tags, "nf.ami", "EC2_AMI_ID");
    putIfNotEmptyOrNull(getenv, tags, "nf.app", "NETFLIX_APP");
    putIfNotEmptyOrNull(getenv, tags, "nf.asg", "NETFLIX_AUTO_SCALE_GROUP");
    putIfNotEmptyOrNull(getenv, tags, "nf.cluster", "NETFLIX_CLUSTER");
    putIfNotEmptyOrNull(getenv, tags, "nf.container", "TITUS_CONTAINER_NAME");
    putIfNotEmptyOrNull(getenv, tags, "nf.node",
        "NETFLIX_INSTANCE_ID",
        "TITUS_TASK_INSTANCE_ID",
        "EC2_INSTANCE_ID");
    putIfNotEmptyOrNull(getenv, tags, "nf.process", "NETFLIX_PROCESS_NAME");
    putIfNotEmptyOrNull(getenv, tags, "nf.region",
        "NETFLIX_REGION",
        "EC2_REGION");
    putIfNotEmptyOrNull(getenv, tags, "nf.shard1", "NETFLIX_SHARD1");
    putIfNotEmptyOrNull(getenv, tags, "nf.shard2", "NETFLIX_SHARD2");
    putIfNotEmptyOrNull(getenv, tags, "nf.stack", "NETFLIX_STACK");
    putIfNotEmptyOrNull(getenv, tags, "nf.vmtype", "EC2_INSTANCE_TYPE");
    putIfNotEmptyOrNull(getenv, tags, "nf.zone", "EC2_AVAILABILITY_ZONE");

    // Build info
    putIfNotEmptyOrNull(getenv, tags, "accountType", "NETFLIX_ACCOUNT_TYPE");
    putIfNotEmptyOrNull(getenv, tags, "buildUrl", "NETFLIX_BUILD_JOB");
    putIfNotEmptyOrNull(getenv, tags, "sourceRepo", "NETFLIX_BUILD_SOURCE_REPO");
    putIfNotEmptyOrNull(getenv, tags, "branch", "NETFLIX_BUILD_BRANCH");
    putIfNotEmptyOrNull(getenv, tags, "commit", "NETFLIX_BUILD_COMMIT");

    // Mantis info
    putIfNotEmptyOrNull(getenv, tags, "mantisJobName", "MANTIS_JOB_NAME");
    putIfNotEmptyOrNull(getenv, tags, "mantisJobId", "MANTIS_JOB_ID");
    putIfNotEmptyOrNull(getenv, tags, "mantisWorkerIndex", "MANTIS_WORKER_INDEX");
    putIfNotEmptyOrNull(getenv, tags, "mantisWorkerNumber", "MANTIS_WORKER_NUMBER");
    putIfNotEmptyOrNull(getenv, tags, "mantisWorkerStageNumber", "MANTIS_WORKER_STAGE_NUMBER");
    putIfNotEmptyOrNull(getenv, tags, "mantisUser", "MANTIS_USER");

    return tags;
  }