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

Method deleteByLabels

prometheus/vec.go:410–427  ·  view source on GitHub ↗

deleteByLabels deletes a metric if the given labels are present in the metric.

(labels Labels, curry []curriedLabelValue)

Source from the content-addressed store, hash-verified

408
409// deleteByLabels deletes a metric if the given labels are present in the metric.
410func (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.

Callers 1

DeletePartialMatchMethod · 0.80

Calls 1

Tested by

no test coverage detected