add delete to gaugeVec, histogramVec, summaryVec since kubelet requires it

This commit is contained in:
Han Kang 2019-08-19 11:04:40 -07:00
parent f4521bf5a2
commit 8b9a05fe82
3 changed files with 42 additions and 0 deletions

View File

@ -148,3 +148,17 @@ func (v *GaugeVec) With(labels prometheus.Labels) GaugeMetric {
} }
return v.GaugeVec.With(labels) return v.GaugeVec.With(labels)
} }
// Delete deletes the metric where the variable labels are the same as those
// passed in as labels. It returns true if a metric was deleted.
//
// It is not an error if the number and names of the Labels are inconsistent
// with those of the VariableLabels in Desc. However, such inconsistent Labels
// can never match an actual metric, so the method will always return false in
// that case.
func (v *GaugeVec) Delete(labels prometheus.Labels) bool {
if !v.IsCreated() {
return false // since we haven't created the metric, we haven't deleted a metric with the passed in values
}
return v.GaugeVec.Delete(labels)
}

View File

@ -143,3 +143,17 @@ func (v *HistogramVec) With(labels prometheus.Labels) ObserverMetric {
} }
return v.HistogramVec.With(labels) return v.HistogramVec.With(labels)
} }
// Delete deletes the metric where the variable labels are the same as those
// passed in as labels. It returns true if a metric was deleted.
//
// It is not an error if the number and names of the Labels are inconsistent
// with those of the VariableLabels in Desc. However, such inconsistent Labels
// can never match an actual metric, so the method will always return false in
// that case.
func (v *HistogramVec) Delete(labels prometheus.Labels) bool {
if !v.IsCreated() {
return false // since we haven't created the metric, we haven't deleted a metric with the passed in values
}
return v.HistogramVec.Delete(labels)
}

View File

@ -150,3 +150,17 @@ func (v *SummaryVec) With(labels prometheus.Labels) ObserverMetric {
} }
return v.SummaryVec.With(labels) return v.SummaryVec.With(labels)
} }
// Delete deletes the metric where the variable labels are the same as those
// passed in as labels. It returns true if a metric was deleted.
//
// It is not an error if the number and names of the Labels are inconsistent
// with those of the VariableLabels in Desc. However, such inconsistent Labels
// can never match an actual metric, so the method will always return false in
// that case.
func (v *SummaryVec) Delete(labels prometheus.Labels) bool {
if !v.IsCreated() {
return false // since we haven't created the metric, we haven't deleted a metric with the passed in values
}
return v.SummaryVec.Delete(labels)
}