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)
| 105 | // need this function if they implement their own Metric or instantiate a Desc |
| 106 | // (with NewDesc) directly. |
| 107 | func 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 | |
| 130 | type invalidMetric struct { |
| 131 | desc *Desc |