deleteByLabels deletes a metric if the given labels are present in the metric.
(labels Labels, curry []curriedLabelValue)
| 408 | |
| 409 | // deleteByLabels deletes a metric if the given labels are present in the metric. |
| 410 | func (m *metricMap) deleteByLabels(labels Labels, curry []curriedLabelValue) int { |
| 411 | m.mtx.Lock() |
| 412 | defer m.mtx.Unlock() |
| 413 | |
| 414 | var numDeleted int |
| 415 | |
| 416 | for h, metrics := range m.metrics { |
| 417 | i := findMetricWithPartialLabels(m.desc, metrics, labels, curry) |
| 418 | if i >= len(metrics) { |
| 419 | // Didn't find matching labels in this metric slice. |
| 420 | continue |
| 421 | } |
| 422 | delete(m.metrics, h) |
| 423 | numDeleted++ |
| 424 | } |
| 425 | |
| 426 | return numDeleted |
| 427 | } |
| 428 | |
| 429 | // findMetricWithPartialLabel returns the index of the matching metric or |
| 430 | // len(metrics) if not found. |
no test coverage detected