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

Function wrapDesc

prometheus/wrap.go:223–248  ·  view source on GitHub ↗
(desc *Desc, prefix string, labels Labels)

Source from the content-addressed store, hash-verified

221}
222
223func wrapDesc(desc *Desc, prefix string, labels Labels) *Desc {
224 constLabels := Labels{}
225 for _, lp := range desc.constLabelPairs {
226 constLabels[*lp.Name] = *lp.Value
227 }
228 for ln, lv := range labels {
229 if _, alreadyUsed := constLabels[ln]; alreadyUsed {
230 return &Desc{
231 fqName: desc.fqName,
232 help: desc.help,
233 variableLabels: desc.variableLabels,
234 constLabelPairs: desc.constLabelPairs,
235 err: fmt.Errorf("attempted wrapping with already existing label name %q", ln),
236 }
237 }
238 constLabels[ln] = lv
239 }
240 // NewDesc will do remaining validations.
241 newDesc := V2.NewDesc(prefix+desc.fqName, desc.help, desc.variableLabels, constLabels)
242 // Propagate errors if there was any. This will override any errer
243 // created by NewDesc above, i.e. earlier errors get precedence.
244 if desc.err != nil {
245 newDesc.err = desc.err
246 }
247 return newDesc
248}

Callers 2

DescribeMethod · 0.85
DescMethod · 0.85

Calls 1

NewDescMethod · 0.80

Tested by

no test coverage detected