Skip to content

Commit 4923292

Browse files
authored
Merge pull request kubernetes#81579 from logicalhan/counter-delete
add delete to counterVec wrapper, since we require it in the kubelet
2 parents cb7c98e + 3150b2b commit 4923292

File tree

1 file changed

+14
-0
lines changed
  • staging/src/k8s.io/component-base/metrics

1 file changed

+14
-0
lines changed

staging/src/k8s.io/component-base/metrics/counter.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,3 +149,17 @@ func (v *CounterVec) With(labels prometheus.Labels) CounterMetric {
149149
}
150150
return v.CounterVec.With(labels)
151151
}
152+
153+
// Delete deletes the metric where the variable labels are the same as those
154+
// passed in as labels. It returns true if a metric was deleted.
155+
//
156+
// It is not an error if the number and names of the Labels are inconsistent
157+
// with those of the VariableLabels in Desc. However, such inconsistent Labels
158+
// can never match an actual metric, so the method will always return false in
159+
// that case.
160+
func (v *CounterVec) Delete(labels prometheus.Labels) bool {
161+
if !v.IsCreated() {
162+
return false // since we haven't created the metric, we haven't deleted a metric with the passed in values
163+
}
164+
return v.CounterVec.Delete(labels)
165+
}

0 commit comments

Comments
 (0)