code: func parseName(s string) (string, string) {
  
  	var i int
  	allowEqual := false
  
  FOR:
  	for braces := 0; i < len(s); i++ {
  		// if the current expression is a metric name with ";" (59) we should
  		// allow the "=" (61) character to be part of the metric name
  		if isNameChar(s[i]) || (allowEqual && s[i] == 61) {
  			if s[i] == 59 {
  				allowEqual = true
  			}
  			continue
  		}
  
  		switch s[i] {
  		case '{':
  			braces++
  		case '}':
  			if braces == 0 {
  				break FOR
  
  			}
  			braces--
  		case ',':
  			if braces == 0 {
  				break FOR
  			}
  		default:
  			break FOR
  		}
  	}
  
  	if i == len(s) {
  		return s, ""
  	}
  
  	return s[:i], s[i:]
  }
docs: // parseName parses a "name" which is either:
  // 1) a metric expression
  // 2) the key of a keyword argument
  // 3) a function name
  // It's up to the caller to determine which, based on context. E.g.:
  // * if leftover data starts with '(' then assume 3 and validate function name
  // * if leftover data starts with '=' assume 2
  // * fallback to assuming 1.
  // it returns the parsed name and any leftover data