MCPcopy Index your code
hub / github.com/coder/coder / cacheKeyForDesc

Function cacheKeyForDesc

coderd/prometheusmetrics/aggregator.go:400–414  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

398// for strings.Builder returned errors from these functions are always nil.
399// nolint:revive
400func 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.

Callers 2

getOrCreateDescMethod · 0.85

Calls 2

WriteStringMethod · 0.80
StringMethod · 0.45

Tested by 1