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

Function BuildFQName

prometheus/metric.go:107–128  ·  view source on GitHub ↗

BuildFQName joins the given three name components by "_". Empty name components are ignored. If the name parameter itself is empty, an empty string is returned, no matter what. Metric implementations included in this library use this function internally to generate the fully-qualified metric name fr

(namespace, subsystem, name string)

Source from the content-addressed store, hash-verified

105// need this function if they implement their own Metric or instantiate a Desc
106// (with NewDesc) directly.
107func BuildFQName(namespace, subsystem, name string) string {
108 if name == "" {
109 return ""
110 }
111
112 sb := strings.Builder{}
113 sb.Grow(len(namespace) + len(subsystem) + len(name) + 2)
114
115 if namespace != "" {
116 sb.WriteString(namespace)
117 sb.WriteString("_")
118 }
119
120 if subsystem != "" {
121 sb.WriteString(subsystem)
122 sb.WriteString("_")
123 }
124
125 sb.WriteString(name)
126
127 return sb.String()
128}
129
130type invalidMetric struct {
131 desc *Desc

Callers 15

rm2promFunction · 0.92
NewUntypedFuncFunction · 0.85
NewGoCollectorFunction · 0.85
NewCounterFunction · 0.85
NewCounterVecMethod · 0.85
NewCounterFuncFunction · 0.85
NewHistogramFunction · 0.85
NewHistogramVecMethod · 0.85
NewSummaryFunction · 0.85
NewSummaryVecMethod · 0.85
TestBuildFQNameFunction · 0.85

Calls 1

StringMethod · 0.45

Tested by 1

TestBuildFQNameFunction · 0.68