cacheKeyForDesc is used to determine the cache key for a set of labels/extra labels. Used with the aggregators description cache. for strings.Builder returned errors from these functions are always nil. nolint:revive
(name string, baseLabelNames []string, extraLabels []*agentproto.Stats_Metric_Label)
| 398 | // for strings.Builder returned errors from these functions are always nil. |
| 399 | // nolint:revive |
| 400 | func cacheKeyForDesc(name string, baseLabelNames []string, extraLabels []*agentproto.Stats_Metric_Label) string { |
| 401 | var b strings.Builder |
| 402 | hint := len(name) + (len(baseLabelNames)+len(extraLabels))*8 |
| 403 | b.Grow(hint) |
| 404 | b.WriteString(name) |
| 405 | for _, ln := range baseLabelNames { |
| 406 | b.WriteByte('|') |
| 407 | b.WriteString(ln) |
| 408 | } |
| 409 | for _, l := range extraLabels { |
| 410 | b.WriteByte('|') |
| 411 | b.WriteString(l.Name) |
| 412 | } |
| 413 | return b.String() |
| 414 | } |
| 415 | |
| 416 | // getOrCreateDec checks if we already have a metric description in the aggregators cache for a given combination of base |
| 417 | // labels and extra labels. If we do not, we create a new description and cache it. |