src/main/java/com/github/sps/metrics/opentsdb/OpenTsdbMetric.java
public static String fixEncodedTagsInNameAfterPrefix(final String name) {
        if (name == null)
            return name;

        int tagStart = name.indexOf("TAG(");

        if (tagStart == -1)
            return name; // no tags in this name

        if (tagStart == 0)
            return name; // tag string is already correct

        // extract the "TAG(...)" string from the middle of the name and put it at the front.
        int tagEnd = name.lastIndexOf(')');
        if (tagEnd == -1) {
            throw new IllegalArgumentException("Tag definition missing closing parenthesis for metric '" + name + "'");
        }

        String tagString = name.substring(tagStart, tagEnd+1);
        return tagString + name.substring(0, tagStart) + name.substring(tagEnd+1);
    }
public static String fixEncodedTagsInNameAfterPrefix(final String name) {
        if (name == null)
            return name;

        int tagStart = name.indexOf("TAG(");

        if (tagStart == -1)
            return name; // no tags in this name

        if (tagStart == 0)
            return name; // tag string is already correct

        // extract the "TAG(...)" string from the middle of the name and put it at the front.
        int tagEnd = name.lastIndexOf(')');
        if (tagEnd == -1) {
            throw new IllegalArgumentException("Tag definition missing closing parenthesis for metric '" + name + "'");
        }

        String tagString = name.substring(tagStart, tagEnd+1);
        return tagString + name.substring(0, tagStart) + name.substring(tagEnd+1);
    }
Call this function whenever a potentially tag-encoded name is prefixed.

@param name a metric name with encoded tag strings that has been prefixed.
@return a fixed metric name