func (t *tenantUsage) getSeries(labels, values []string, maxCardinality uint64) *bucket {
(buffer []string, maxCardinality uint64)
| 170 | |
| 171 | // func (t *tenantUsage) getSeries(labels, values []string, maxCardinality uint64) *bucket { |
| 172 | func (t *tenantUsage) getSeries(buffer []string, maxCardinality uint64) *bucket { |
| 173 | h := hash(t.sortedKeys, buffer) |
| 174 | |
| 175 | b := t.series[h] |
| 176 | if b == nil { |
| 177 | // Before creating a new series, check for cardinality limit. |
| 178 | if uint64(len(t.series)) >= maxCardinality { |
| 179 | // Overflow |
| 180 | // This tenant is at the maximum number of series. In this case all data |
| 181 | // goes into the final overflow bucket. It has the same dimensions as the |
| 182 | // current configuration, except every label is overridden to the special overflow value. |
| 183 | for k := range buffer { |
| 184 | buffer[k] = overflowLabel |
| 185 | } |
| 186 | h = t.overflow |
| 187 | b = t.series[h] |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | if b == nil { |
| 192 | // First encounter with this series. Initialize it. |
| 193 | // Detach a copy of the values |
| 194 | v := make([]string, len(buffer)) |
| 195 | copy(v, buffer) |
| 196 | b = &bucket{ |
| 197 | // Metric description - constant for this pass now that the dimensions are known |
| 198 | descr: prometheus.NewDesc("tempo_usage_tracker_bytes_received_total", "bytes total received with these attributes", t.sortedKeys, t.constLabels), |
| 199 | labels: v, |
| 200 | } |
| 201 | t.series[h] = b |
| 202 | } |
| 203 | return b |
| 204 | } |
| 205 | |
| 206 | type Tracker struct { |
| 207 | mtx sync.Mutex |