MCPcopy Create free account
hub / github.com/prometheus/common / writeName

Function writeName

expfmt/text_create.go:512–532  ·  view source on GitHub ↗

writeName writes a string as-is if it complies with the legacy naming scheme, or escapes it in double quotes if not.

(w enhancedWriter, name string)

Source from the content-addressed store, hash-verified

510// writeName writes a string as-is if it complies with the legacy naming
511// scheme, or escapes it in double quotes if not.
512func writeName(w enhancedWriter, name string) (int, error) {
513 if model.LegacyValidation.IsValidMetricName(name) {
514 return w.WriteString(name)
515 }
516 var written int
517 var err error
518 err = w.WriteByte('"')
519 written++
520 if err != nil {
521 return written, err
522 }
523 var n int
524 n, err = writeEscapedString(w, name, true)
525 written += n
526 if err != nil {
527 return written, err
528 }
529 err = w.WriteByte('"')
530 written++
531 return written, err
532}

Callers 4

MetricFamilyToTextFunction · 0.85
writeNameAndLabelPairsFunction · 0.85

Calls 4

writeEscapedStringFunction · 0.85
IsValidMetricNameMethod · 0.80
WriteStringMethod · 0.80
WriteByteMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…