MCPcopy
hub / github.com/prometheus/client_golang / constrainLabels

Function constrainLabels

prometheus/vec.go:665–682  ·  view source on GitHub ↗
(desc *Desc, labels Labels)

Source from the content-addressed store, hash-verified

663}
664
665func constrainLabels(desc *Desc, labels Labels) (Labels, func()) {
666 if len(desc.variableLabels.labelConstraints) == 0 {
667 // Fast path when there's no constraints
668 return labels, func() {}
669 }
670
671 constrainedLabels := labelsPool.Get().(Labels)
672 for l, v := range labels {
673 constrainedLabels[l] = desc.variableLabels.constrain(l, v)
674 }
675
676 return constrainedLabels, func() {
677 for k := range constrainedLabels {
678 delete(constrainedLabels, k)
679 }
680 labelsPool.Put(constrainedLabels)
681 }
682}
683
684func constrainLabelValues(desc *Desc, lvs []string, curry []curriedLabelValue) []string {
685 if len(desc.variableLabels.labelConstraints) == 0 {

Callers 3

DeleteMethod · 0.85
DeletePartialMatchMethod · 0.85
GetMetricWithMethod · 0.85

Calls 1

constrainMethod · 0.80

Tested by

no test coverage detected