Build a new metric name using the specific path components.

@param parts Path of the new metric name.
@return A newly created metric name with the specified path.
348329
public static MetricName build(String... parts) {
        if (parts == null || parts.length == 0)
            return MetricName.EMPTY;

        if (parts.length == 1)
            return new MetricName(parts[0], EMPTY_TAGS);

        return new MetricName(buildName(parts), EMPTY_TAGS);
    }
1305502
protected function buildChangesPath(string ...$parts)
    {
        return static::buildPath('repositories', $this->username, $this->repo, 'issues', $this->issue, 'changes', ...$parts);
    }
1292693
def metric_descriptor_path(cls, project, metric_descriptor):
        """"""
        return google.api_core.path_template.expand(
            "projects/{project}/metricDescriptors/{metric_descriptor=**}",
            project=project,
            metric_descriptor=metric_descriptor,
        )
26679
public String[] getPartNames()
    {
        Set s = _partMap.keySet();
        return (String[]) s.toArray(new String[s.size()]);
    }
111353
public MetricNameBuilder addDimension(Dimension dimension, boolean permute) throws MetricsNameSyntaxException {
        return addDimension(dimension.getName(), dimension.getValue(), false);
    }
514964
public static String join(String joiner, String... parts) {
        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < parts.length; i++) {
            builder.append(parts[i]);
            if (i < parts.length - 1) {
                builder.append(joiner);
            }
        }
        return builder.toString();
    }
262041
public static Metric from(String fullName, double value) {
    String[] pieces = fullName.split("\\.");
    Preconditions.checkArgument(pieces.length > 1, "Incorrect metrics name: %s.", fullName);

    String hostname = null;
    String id = null;
    String name = null;
    int tagStartIdx = 0;
    // Master or cluster metrics don't have hostname included.
    if (pieces[0].equals(MetricsSystem.InstanceType.MASTER.toString())
        || pieces[0].equals(MetricsSystem.CLUSTER.toString())) {
      name = pieces[1];
      tagStartIdx = 2;
    } else {
      if (pieces[1].contains(ID_SEPARATOR)) {
        String[] ids = pieces[1].split(ID_SEPARATOR);
        hostname = ids[0];
        id = ids[1];
      } else {
        hostname = pieces[1];
      }
      name = pieces[2];
      tagStartIdx = 3;
    }
    MetricsSystem.InstanceType instance = MetricsSystem.InstanceType.fromString(pieces[0]);
    Metric metric = new Metric(instance, hostname, id, name, value);

    // parse tags
    for (int i = tagStartIdx; i < pieces.length; i++) {
      String tagStr = pieces[i];
      if (!tagStr.contains(TAG_SEPARATOR)) {
        // Unknown tag
        continue;
      }
      int tagSeparatorIdx = tagStr.indexOf(TAG_SEPARATOR);
      metric.addTag(tagStr.substring(0, tagSeparatorIdx), tagStr.substring(tagSeparatorIdx + 1));
    }
    return metric;
  }
245565
public static String pathStringFromComponents(String[] components) {
        if (null == components || components.length == 0) {
            return null;
        }
        return cleanPath(join(components, SEPARATOR));
    }
709177
protected void addMetric(String name, Metric metric) {
		if (metric == null) {
			LOG.warn("Ignoring attempted registration of a metric due to being null for name {}.", name);
			return;
		}
		// add the metric only if the group is still open
		synchronized (this) {
			if (!closed) {
				// immediately put without a 'contains' check to optimize the common case (no collision)
				// collisions are resolved later
				Metric prior = metrics.put(name, metric);

				// check for collisions with other metric names
				if (prior == null) {
					// no other metric with this name yet

					if (groups.containsKey(name)) {
						// we warn here, rather than failing, because metrics are tools that should not fail the
						// program when used incorrectly
						LOG.warn("Name collision: Adding a metric with the same name as a metric subgroup: '" +
								name + "'. Metric might not get properly reported. " + Arrays.toString(scopeComponents));
					}

					registry.register(metric, name, this);
				}
				else {
					// we had a collision. put back the original value
					metrics.put(name, prior);

					// we warn here, rather than failing, because metrics are tools that should not fail the
					// program when used incorrectly
					LOG.warn("Name collision: Group already contains a Metric with the name '" +
							name + "'. Metric will not be reported." + Arrays.toString(scopeComponents));
				}
			}
		}
	}
391694
public MultipartBuilder addPart(NetworkRequest part) {
        if (part == null) {
            throw new NullPointerException("part == null");
        }
        parts.add(part);
        return this;
    }
32764
protected MatchingPart toPart(List<MatchingPart> leadingParts, String part) {
        if (ANY_INDICATOR.equals(part)) {
            return getAnyPart();
        }
        // This part is a constant string
        return createConstantPart(part);
    }
274379
static List<String> pathParts(String path) {
        String[] pathParts = path.split("/");
        List<String> parts = new ArrayList<>(pathParts.length);
        String pathSoFar = "";
        for (String pathPart : pathParts) {
            if (!pathPart.equals("")) {
                pathSoFar += "/" + pathPart;
                parts.add(pathSoFar);
            }
        }
        return parts;
    }
445685
public MetricNameBuilder addDimension(String name, String value) throws MetricsNameSyntaxException {
        return addDimension(name, value, false);
    }
1069397
public PublicEndpoint withMetrics(java.util.Map<String, Double> metrics) {
        setMetrics(metrics);
        return this;
    }
220734
public Metric add(String name, MeasurableStat stat, MetricConfig config) {
        return add(name, "", stat, config);
    }
590510
public static String metricName(String type, String topologyId, String componentId, int taskId, String streamId, String group, String name) {
        return concat(type, topologyId, componentId, taskId, streamId, group, name);
    }
1135849
@SuppressWarnings("unchecked")
    public <T extends Metric> T register(String name, T metric) throws IllegalArgumentException {
        if (metric instanceof MetricSet) {
            registerAll(name, (MetricSet) metric);
        } else {
            final Metric existing = metrics.putIfAbsent(name, metric);
            if (existing == null) {
                onMetricAdded(name, metric);
            } else {
                throw new IllegalArgumentException("A metric named " + name + " already exists");
            }
        }
        return metric;
    }