docs: public static String parseWithMetric(final String metric,
                                         final HashMap<String, String> tags) {
      final int curly = metric.indexOf('{');
      if (curly < 0) {
        return metric;
      }
      final int len = metric.length();
      if (metric.charAt(len - 1) != '}') {  // "foo{"
        throw new IllegalArgumentException("Missing '}' at the end of: " + metric);
      } else if (curly == len - 2) {  // "foo{}"
        return metric.substring(0, len - 2);
      }
      // substring the tags out of "foo{a=b,...,x=y}" and parse them.
      for (final String tag : splitString(metric.substring(curly + 1, len - 1),
                                          ',')) {
        try {
          parse(tags, tag);
        } catch (IllegalArgumentException e) {
          throw new IllegalArgumentException("When parsing tag '" + tag
                                             + "': " + e.getMessage());
        }
      }
      // Return the "foo" part of "foo{a=b,...,x=y}"
      return metric.substring(0, curly);
    }