@Test public void shouldReturnANameIfTryingToRegisterMetricWithExactlyTenTags() throws Exception { Map<String, String> tags = IntStream.range(0, 10) .boxed() .collect(Collectors.toMap(i -> "tag" + i, i -> "tagVal" + i)); assertThat(tags.size()).isEqualTo(10); assertThat(MetricNameUtils.getMetricName(METRIC_NAME, tags)).contains(METRIC_NAME); }
public static String getMetricName(String metricName, Map<String, String> tags) { Preconditions.checkArgument(tags.size() <= MAX_ALLOWED_TAGS, "Too many tags set on the metric %s. " + "Maximum allowed number of tags is %s, found %s.", metricName, MAX_ALLOWED_TAGS, tags.size()); validateMetricComponentName(metricName, "metric"); validateMetricTagNames(tags); return tags.entrySet().stream() .map(e -> e.getKey() + EQUALS + e.getValue()) .collect(Collectors.joining(DELIMITER, metricName + DELIMITER, "")); }
MetricNameUtils { public static String getMetricName(String metricName, Map<String, String> tags) { Preconditions.checkArgument(tags.size() <= MAX_ALLOWED_TAGS, "Too many tags set on the metric %s. " + "Maximum allowed number of tags is %s, found %s.", metricName, MAX_ALLOWED_TAGS, tags.size()); validateMetricComponentName(metricName, "metric"); validateMetricTagNames(tags); return tags.entrySet().stream() .map(e -> e.getKey() + EQUALS + e.getValue()) .collect(Collectors.joining(DELIMITER, metricName + DELIMITER, "")); } }
MetricNameUtils { public static String getMetricName(String metricName, Map<String, String> tags) { Preconditions.checkArgument(tags.size() <= MAX_ALLOWED_TAGS, "Too many tags set on the metric %s. " + "Maximum allowed number of tags is %s, found %s.", metricName, MAX_ALLOWED_TAGS, tags.size()); validateMetricComponentName(metricName, "metric"); validateMetricTagNames(tags); return tags.entrySet().stream() .map(e -> e.getKey() + EQUALS + e.getValue()) .collect(Collectors.joining(DELIMITER, metricName + DELIMITER, "")); } private  MetricNameUtils(); }
MetricNameUtils { public static String getMetricName(String metricName, Map<String, String> tags) { Preconditions.checkArgument(tags.size() <= MAX_ALLOWED_TAGS, "Too many tags set on the metric %s. " + "Maximum allowed number of tags is %s, found %s.", metricName, MAX_ALLOWED_TAGS, tags.size()); validateMetricComponentName(metricName, "metric"); validateMetricTagNames(tags); return tags.entrySet().stream() .map(e -> e.getKey() + EQUALS + e.getValue()) .collect(Collectors.joining(DELIMITER, metricName + DELIMITER, "")); } private  MetricNameUtils(); static String getMetricName(String metricName, Map<String, String> tags); }
MetricNameUtils { public static String getMetricName(String metricName, Map<String, String> tags) { Preconditions.checkArgument(tags.size() <= MAX_ALLOWED_TAGS, "Too many tags set on the metric %s. " + "Maximum allowed number of tags is %s, found %s.", metricName, MAX_ALLOWED_TAGS, tags.size()); validateMetricComponentName(metricName, "metric"); validateMetricTagNames(tags); return tags.entrySet().stream() .map(e -> e.getKey() + EQUALS + e.getValue()) .collect(Collectors.joining(DELIMITER, metricName + DELIMITER, "")); } private  MetricNameUtils(); static String getMetricName(String metricName, Map<String, String> tags);  }