groupingKeyFor creates a grouping key from the provided map of grouping labels. The grouping key is created by joining all label names and values together with model.SeparatorByte as a separator. The label names are sorted lexicographically before joining. In that way, the grouping key is both repro
(labels map[string]string)
| 460 | // lexicographically before joining. In that way, the grouping key is both |
| 461 | // reproducible and unique. |
| 462 | func groupingKeyFor(labels map[string]string) string { |
| 463 | if len(labels) == 0 { // Super fast path. |
| 464 | return "" |
| 465 | } |
| 466 | |
| 467 | labelNames := make([]string, 0, len(labels)) |
| 468 | for labelName := range labels { |
| 469 | labelNames = append(labelNames, labelName) |
| 470 | } |
| 471 | sort.Strings(labelNames) |
| 472 | |
| 473 | sb := strings.Builder{} |
| 474 | for i, labelName := range labelNames { |
| 475 | sb.WriteString(labelName) |
| 476 | sb.WriteByte(model.SeparatorByte) |
| 477 | sb.WriteString(labels[labelName]) |
| 478 | if i+1 < len(labels) { // No separator at the end. |
| 479 | sb.WriteByte(model.SeparatorByte) |
| 480 | } |
| 481 | } |
| 482 | return sb.String() |
| 483 | } |
| 484 | |
| 485 | // extractPredefinedHelpStrings extracts all the HELP strings from the provided |
| 486 | // gatherer so that the DiskMetricStore can fix deviations in pushed metrics. |
no outgoing calls
searching dependent graphs…