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

Method String

prometheus/desc.go:185–211  ·  prometheus/desc.go::Desc.String
()

Source from the content-addressed store, hash-verified

183}
184
185func (d *Desc) String() string {
186 lpStrings := make([]string, 0, len(d.constLabelPairs))
187 for _, lp := range d.constLabelPairs {
188 lpStrings = append(
189 lpStrings,
190 fmt.Sprintf("%s=%q", lp.GetName(), lp.GetValue()),
191 )
192 }
193 vlStrings := []string{}
194 if d.variableLabels != nil {
195 vlStrings = make([]string, 0, len(d.variableLabels.names))
196 for _, vl := range d.variableLabels.names {
197 if fn, ok := d.variableLabels.labelConstraints[vl]; ok && fn != nil {
198 vlStrings = append(vlStrings, fmt.Sprintf("c(%s)", vl))
199 } else {
200 vlStrings = append(vlStrings, vl)
201 }
202 }
203 }
204 return fmt.Sprintf(
205 "Desc{fqName: %q, help: %q, constLabels: {%s}, variableLabels: {%s}}",
206 d.fqName,
207 d.help,
208 strings.Join(lpStrings, ","),
209 strings.Join(vlStrings, ","),
210 )
211}

Callers 15

TestCollectorFuncFunction · 0.95
MakeLabelPairsFunction · 0.45
newExemplarFunction · 0.45
toNormalizedJSONFunction · 0.45
ExampleGatherersFunction · 0.45
WriteMethod · 0.45
TestCounterAddFunction · 0.45
TestCounterExemplarFunction · 0.45

Calls 1

GetValueMethod · 0.45

Tested by 15

TestCollectorFuncFunction · 0.76
toNormalizedJSONFunction · 0.36
ExampleGatherersFunction · 0.36
TestCounterAddFunction · 0.36
TestCounterExemplarFunction · 0.36
TestHistogramExemplarFunction · 0.36