Rename metric vector method `Reset` to `Clear`

This it to bring client_golang in line with the client library
guidelines. See #218.

Signed-off-by: beorn7 <beorn@soundcloud.com>
This commit is contained in:
beorn7 2018-10-16 15:02:45 +02:00
parent 69a543ac3b
commit f53420cd1d
5 changed files with 10 additions and 10 deletions

View File

@ -154,7 +154,7 @@ func NewCounterVec(opts CounterOpts, labelNames []string) *CounterVec {
// SummaryVec example. // SummaryVec example.
// //
// Keeping the Counter for later use is possible (and should be considered if // Keeping the Counter for later use is possible (and should be considered if
// performance is critical), but keep in mind that Reset, DeleteLabelValues and // performance is critical), but keep in mind that Clear, DeleteLabelValues and
// Delete can be used to delete the Counter from the CounterVec. In that case, // Delete can be used to delete the Counter from the CounterVec. In that case,
// the Counter will still exist, but it will not be exported anymore, even if a // the Counter will still exist, but it will not be exported anymore, even if a
// Counter with the same label values is created later. // Counter with the same label values is created later.
@ -230,7 +230,7 @@ func (v *CounterVec) With(labels Labels) Counter {
// The metrics contained in the CounterVec are shared between the curried and // The metrics contained in the CounterVec are shared between the curried and
// uncurried vectors. They are just accessed differently. Curried and uncurried // uncurried vectors. They are just accessed differently. Curried and uncurried
// vectors behave identically in terms of collection. Only one must be // vectors behave identically in terms of collection. Only one must be
// registered with a given registry (usually the uncurried version). The Reset // registered with a given registry (usually the uncurried version). The Clear
// method deletes all metrics, even if called on a curried vector. // method deletes all metrics, even if called on a curried vector.
func (v *CounterVec) CurryWith(labels Labels) (*CounterVec, error) { func (v *CounterVec) CurryWith(labels Labels) (*CounterVec, error) {
vec, err := v.curryWith(labels) vec, err := v.curryWith(labels)

View File

@ -414,7 +414,7 @@ func NewHistogramVec(opts HistogramOpts, labelNames []string) *HistogramVec {
// any observations. // any observations.
// //
// Keeping the Histogram for later use is possible (and should be considered if // Keeping the Histogram for later use is possible (and should be considered if
// performance is critical), but keep in mind that Reset, DeleteLabelValues and // performance is critical), but keep in mind that Clear, DeleteLabelValues and
// Delete can be used to delete the Histogram from the HistogramVec. In that case, the // Delete can be used to delete the Histogram from the HistogramVec. In that case, the
// Histogram will still exist, but it will not be exported anymore, even if a // Histogram will still exist, but it will not be exported anymore, even if a
// Histogram with the same label values is created later. See also the CounterVec // Histogram with the same label values is created later. See also the CounterVec
@ -491,7 +491,7 @@ func (v *HistogramVec) With(labels Labels) Observer {
// The metrics contained in the HistogramVec are shared between the curried and // The metrics contained in the HistogramVec are shared between the curried and
// uncurried vectors. They are just accessed differently. Curried and uncurried // uncurried vectors. They are just accessed differently. Curried and uncurried
// vectors behave identically in terms of collection. Only one must be // vectors behave identically in terms of collection. Only one must be
// registered with a given registry (usually the uncurried version). The Reset // registered with a given registry (usually the uncurried version). The Clear
// method deletes all metrics, even if called on a curried vector. // method deletes all metrics, even if called on a curried vector.
func (v *HistogramVec) CurryWith(labels Labels) (ObserverVec, error) { func (v *HistogramVec) CurryWith(labels Labels) (ObserverVec, error) {
vec, err := v.curryWith(labels) vec, err := v.curryWith(labels)

View File

@ -426,7 +426,7 @@ func NewSummaryVec(opts SummaryOpts, labelNames []string) *SummaryVec {
// any observations. // any observations.
// //
// Keeping the Summary for later use is possible (and should be considered if // Keeping the Summary for later use is possible (and should be considered if
// performance is critical), but keep in mind that Reset, DeleteLabelValues and // performance is critical), but keep in mind that Clear, DeleteLabelValues and
// Delete can be used to delete the Summary from the SummaryVec. In that case, // Delete can be used to delete the Summary from the SummaryVec. In that case,
// the Summary will still exist, but it will not be exported anymore, even if a // the Summary will still exist, but it will not be exported anymore, even if a
// Summary with the same label values is created later. See also the CounterVec // Summary with the same label values is created later. See also the CounterVec
@ -503,7 +503,7 @@ func (v *SummaryVec) With(labels Labels) Observer {
// The metrics contained in the SummaryVec are shared between the curried and // The metrics contained in the SummaryVec are shared between the curried and
// uncurried vectors. They are just accessed differently. Curried and uncurried // uncurried vectors. They are just accessed differently. Curried and uncurried
// vectors behave identically in terms of collection. Only one must be // vectors behave identically in terms of collection. Only one must be
// registered with a given registry (usually the uncurried version). The Reset // registered with a given registry (usually the uncurried version). The Clear
// method deletes all metrics, even if called on a curried vector. // method deletes all metrics, even if called on a curried vector.
func (v *SummaryVec) CurryWith(labels Labels) (ObserverVec, error) { func (v *SummaryVec) CurryWith(labels Labels) (ObserverVec, error) {
vec, err := v.curryWith(labels) vec, err := v.curryWith(labels)

View File

@ -234,8 +234,8 @@ func (m *metricMap) Collect(ch chan<- Metric) {
} }
} }
// Reset deletes all metrics in this vector. // Clear deletes all metrics in this vector.
func (m *metricMap) Reset() { func (m *metricMap) Clear() {
m.mtx.Lock() m.mtx.Lock()
defer m.mtx.Unlock() defer m.mtx.Unlock()

View File

@ -150,7 +150,7 @@ func TestMetricVecWithCollisions(t *testing.T) {
} }
func testMetricVec(t *testing.T, vec *GaugeVec) { func testMetricVec(t *testing.T, vec *GaugeVec) {
vec.Reset() // Actually test Reset now! vec.Clear() // Actually test Clear now!
var pair [2]string var pair [2]string
// Keep track of metrics. // Keep track of metrics.
@ -199,7 +199,7 @@ func testMetricVec(t *testing.T, vec *GaugeVec) {
t.Fatalf("unexpected number of metrics: %v != %v", total, len(expected)) t.Fatalf("unexpected number of metrics: %v != %v", total, len(expected))
} }
vec.Reset() vec.Clear()
if len(vec.metricMap.metrics) > 0 { if len(vec.metricMap.metrics) > 0 {
t.Fatalf("reset failed") t.Fatalf("reset failed")