stats/metrickey.go
func MetricWithPrefix(prefix, name string, tags map[string]string) string {
	buf := bufPool.Get().(*bytes.Buffer)
	buf.Reset()

	if prefix != "" {
		buf.WriteString(prefix)
	}
	buf.WriteString(name)

	addKeys := make([]string, 0, 5)
	switch {
	case strings.HasPrefix(name, "outbound"):
		addKeys = append(addKeys, "service", "target-service", "target-endpoint")
		if strings.HasPrefix(name, "outbound.calls.retries") {
			addKeys = append(addKeys, "retry-count")
		}
	case strings.HasPrefix(name, "inbound"):
		addKeys = append(addKeys, "calling-service", "service", "endpoint")
	}

	for _, k := range addKeys {
		buf.WriteByte('.')
		v, ok := tags[k]
		if ok {
			writeClean(buf, v)
		} else {
			buf.WriteString("no-")
			buf.WriteString(k)
		}
	}

	m := buf.String()
	bufPool.Put(buf)
	return m
}
func MetricWithPrefix(prefix, name string, tags map[string]string) string {
	buf := bufPool.Get().(*bytes.Buffer)
	buf.Reset()

	if prefix != "" {
		buf.WriteString(prefix)
	}
	buf.WriteString(name)

	addKeys := make([]string, 0, 5)
	switch {
	case strings.HasPrefix(name, "outbound"):
		addKeys = append(addKeys, "service", "target-service", "target-endpoint")
		if strings.HasPrefix(name, "outbound.calls.retries") {
			addKeys = append(addKeys, "retry-count")
		}
	case strings.HasPrefix(name, "inbound"):
		addKeys = append(addKeys, "calling-service", "service", "endpoint")
	}

	for _, k := range addKeys {
		buf.WriteByte('.')
		v, ok := tags[k]
		if ok {
			writeClean(buf, v)
		} else {
			buf.WriteString("no-")
			buf.WriteString(k)
		}
	}

	m := buf.String()
	bufPool.Put(buf)
	return m
}
// MetricWithPrefix is the default mapping for metrics to statsd keys.