Skip to content

Commit 8b9a05f

Browse files
author
Han Kang
committed
add delete to gaugeVec, histogramVec, summaryVec since kubelet requires it
1 parent f4521bf commit 8b9a05f

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

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

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

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

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

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

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

0 commit comments

Comments
 (0)