numLabelsToString returns a string representation of a map representing numeric labels.
(numLabels map[string][]int64, numUnits map[string][]string)
| 694 | // numLabelsToString returns a string representation of a map |
| 695 | // representing numeric labels. |
| 696 | func numLabelsToString(numLabels map[string][]int64, numUnits map[string][]string) string { |
| 697 | ls := []string{} |
| 698 | for k, v := range numLabels { |
| 699 | units := numUnits[k] |
| 700 | var labelString string |
| 701 | if len(units) == len(v) { |
| 702 | values := make([]string, len(v)) |
| 703 | for i, vv := range v { |
| 704 | values[i] = fmt.Sprintf("%d %s", vv, units[i]) |
| 705 | } |
| 706 | labelString = fmt.Sprintf("%s:%v", k, values) |
| 707 | } else { |
| 708 | labelString = fmt.Sprintf("%s:%v", k, v) |
| 709 | } |
| 710 | ls = append(ls, labelString) |
| 711 | } |
| 712 | sort.Strings(ls) |
| 713 | return strings.Join(ls, " ") |
| 714 | } |
| 715 | |
| 716 | // SetLabel sets the specified key to the specified value for all samples in the |
| 717 | // profile. |
no outgoing calls
no test coverage detected
searching dependent graphs…