Merge branch 'master' into dev-v2
diff --git a/prometheus/counter.go b/prometheus/counter.go
index d463e36..e625e6e 100644
--- a/prometheus/counter.go
+++ b/prometheus/counter.go
@@ -154,8 +154,8 @@
// SummaryVec example.
//
// Keeping the Counter for later use is possible (and should be considered if
-// performance is critical), but keep in mind that Reset, DeleteLabelValues and
-// Delete can be used to delete the Counter from the CounterVec. In that case,
+// performance is critical), but keep in mind that Clear, RemoveLabelValues and
+// Remove can be used to remove the Counter from the CounterVec. In that case,
// the Counter will still exist, but it will not be exported anymore, even if a
// Counter with the same label values is created later.
//
@@ -230,7 +230,7 @@
// The metrics contained in the CounterVec are shared between the curried and
// uncurried vectors. They are just accessed differently. Curried and uncurried
// 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.
func (v *CounterVec) CurryWith(labels Labels) (*CounterVec, error) {
vec, err := v.curryWith(labels)
diff --git a/prometheus/examples_test.go b/prometheus/examples_test.go
index bdb567e..3de9686 100644
--- a/prometheus/examples_test.go
+++ b/prometheus/examples_test.go
@@ -109,13 +109,13 @@
for i := 0; i < 1000000; i++ {
m.Inc()
}
- // Delete a metric from the vector. If you have previously kept a handle
+ // Remove a metric from the vector. If you have previously kept a handle
// to that metric (as above), future updates via that handle will go
// unseen (even if you re-create a metric with the same label set
// later).
- httpReqs.DeleteLabelValues("200", "GET")
+ httpReqs.RemoveLabelValues("200", "GET")
// Same thing with the more verbose Labels syntax.
- httpReqs.Delete(prometheus.Labels{"method": "GET", "code": "200"})
+ httpReqs.Remove(prometheus.Labels{"method": "GET", "code": "200"})
}
func ExampleRegister() {
diff --git a/prometheus/gauge.go b/prometheus/gauge.go
index 71d406b..12d923d 100644
--- a/prometheus/gauge.go
+++ b/prometheus/gauge.go
@@ -165,8 +165,8 @@
// SummaryVec example.
//
// Keeping the Gauge for later use is possible (and should be considered if
-// performance is critical), but keep in mind that Reset, DeleteLabelValues and
-// Delete can be used to delete the Gauge from the GaugeVec. In that case, the
+// performance is critical), but keep in mind that Clear, RemoveLabelValues and
+// Remove can be used to remove the Gauge from the GaugeVec. In that case, the
// Gauge will still exist, but it will not be exported anymore, even if a
// Gauge with the same label values is created later. See also the CounterVec
// example.
@@ -241,7 +241,7 @@
// The metrics contained in the GaugeVec are shared between the curried and
// uncurried vectors. They are just accessed differently. Curried and uncurried
// 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.
func (v *GaugeVec) CurryWith(labels Labels) (*GaugeVec, error) {
vec, err := v.curryWith(labels)
diff --git a/prometheus/histogram.go b/prometheus/histogram.go
index d7ea67b..14515b4 100644
--- a/prometheus/histogram.go
+++ b/prometheus/histogram.go
@@ -381,16 +381,16 @@
// values (same order as the VariableLabels in Desc). If that combination of
// label values is accessed for the first time, a new Histogram is created.
//
-// It is possible to call this method without using the returned Histogram to only
-// create the new Histogram but leave it at its starting value, a Histogram without
-// any observations.
+// It is possible to call this method without using the returned Histogram to
+// only create the new Histogram but leave it at its starting value, a Histogram
+// without any observations.
//
// Keeping the Histogram for later use is possible (and should be considered if
-// performance is critical), but keep in mind that Reset, DeleteLabelValues and
-// 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 with the same label values is created later. See also the CounterVec
-// example.
+// performance is critical), but keep in mind that Clear, RemoveLabelValues and
+// Remove can be used to remove the Histogram from the HistogramVec. In that
+// case, the 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 example.
//
// An error is returned if the number of label values is not the same as the
// number of VariableLabels in Desc (minus any curried labels).
@@ -463,7 +463,7 @@
// The metrics contained in the HistogramVec are shared between the curried and
// uncurried vectors. They are just accessed differently. Curried and uncurried
// 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.
func (v *HistogramVec) CurryWith(labels Labels) (ObserverVec, error) {
vec, err := v.curryWith(labels)
diff --git a/prometheus/promhttp/instrument_server.go b/prometheus/promhttp/instrument_server.go
index 9db2438..e7c737e 100644
--- a/prometheus/promhttp/instrument_server.go
+++ b/prometheus/promhttp/instrument_server.go
@@ -322,23 +322,23 @@
func sanitizeMethod(m string) string {
switch m {
case "GET", "get":
- return "get"
+ return "GET"
case "PUT", "put":
- return "put"
+ return "PUT"
case "HEAD", "head":
- return "head"
+ return "HEAD"
case "POST", "post":
- return "post"
+ return "POST"
case "DELETE", "delete":
- return "delete"
+ return "DELETE"
case "CONNECT", "connect":
- return "connect"
+ return "CONNECT"
case "OPTIONS", "options":
- return "options"
+ return "OPTIONS"
case "NOTIFY", "notify":
- return "notify"
+ return "NOTIFY"
default:
- return strings.ToLower(m)
+ return strings.ToUpper(m)
}
}
diff --git a/prometheus/summary.go b/prometheus/summary.go
index c970fde..288111e 100644
--- a/prometheus/summary.go
+++ b/prometheus/summary.go
@@ -549,8 +549,8 @@
// any observations.
//
// Keeping the Summary for later use is possible (and should be considered if
-// performance is critical), but keep in mind that Reset, DeleteLabelValues and
-// Delete can be used to delete the Summary from the SummaryVec. In that case,
+// performance is critical), but keep in mind that Clear, RemoveLabelValues and
+// Remove can be used to remove the Summary from the SummaryVec. In that case,
// 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
// example.
@@ -626,7 +626,7 @@
// The metrics contained in the SummaryVec are shared between the curried and
// uncurried vectors. They are just accessed differently. Curried and uncurried
// 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.
func (v *SummaryVec) CurryWith(labels Labels) (ObserverVec, error) {
vec, err := v.curryWith(labels)
diff --git a/prometheus/vec.go b/prometheus/vec.go
index 14ed9e8..e2098d4 100644
--- a/prometheus/vec.go
+++ b/prometheus/vec.go
@@ -48,9 +48,9 @@
}
}
-// DeleteLabelValues removes the metric where the variable labels are the same
+// RemoveLabelValues removes the metric where the variable labels are the same
// as those passed in as labels (same order as the VariableLabels in Desc). It
-// returns true if a metric was deleted.
+// returns true if a metric was removed.
//
// It is not an error if the number of label values is not the same as the
// number of VariableLabels in Desc. However, such inconsistent label count can
@@ -58,37 +58,37 @@
// case.
//
// Note that for more than one label value, this method is prone to mistakes
-// caused by an incorrect order of arguments. Consider Delete(Labels) as an
+// caused by an incorrect order of arguments. Consider Remove(Labels) as an
// alternative to avoid that type of mistake. For higher label numbers, the
// latter has a much more readable (albeit more verbose) syntax, but it comes
// with a performance overhead (for creating and processing the Labels map).
// See also the CounterVec example.
-func (m *metricVec) DeleteLabelValues(lvs ...string) bool {
+func (m *metricVec) RemoveLabelValues(lvs ...string) bool {
h, err := m.hashLabelValues(lvs)
if err != nil {
return false
}
- return m.metricMap.deleteByHashWithLabelValues(h, lvs, m.curry)
+ return m.metricMap.removeByHashWithLabelValues(h, lvs, m.curry)
}
-// 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.
+// Remove removes the metric where the variable labels are the same as those
+// passed in as labels. It returns true if a metric was removed.
//
// 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.
//
-// This method is used for the same purpose as DeleteLabelValues(...string). See
+// This method is used for the same purpose as RemoveLabelValues(...string). See
// there for pros and cons of the two methods.
-func (m *metricVec) Delete(labels Labels) bool {
+func (m *metricVec) Remove(labels Labels) bool {
h, err := m.hashLabels(labels)
if err != nil {
return false
}
- return m.metricMap.deleteByHashWithLabels(h, labels, m.curry)
+ return m.metricMap.removeByHashWithLabels(h, labels, m.curry)
}
func (m *metricVec) curryWith(labels Labels) (*metricVec, error) {
@@ -234,8 +234,8 @@
}
}
-// Reset deletes all metrics in this vector.
-func (m *metricMap) Reset() {
+// Clear removes all metrics from this vector.
+func (m *metricMap) Clear() {
m.mtx.Lock()
defer m.mtx.Unlock()
@@ -244,10 +244,10 @@
}
}
-// deleteByHashWithLabelValues removes the metric from the hash bucket h. If
+// removeByHashWithLabelValues removes the metric from the hash bucket h. If
// there are multiple matches in the bucket, use lvs to select a metric and
// remove only that metric.
-func (m *metricMap) deleteByHashWithLabelValues(
+func (m *metricMap) removeByHashWithLabelValues(
h uint64, lvs []string, curry []curriedLabelValue,
) bool {
m.mtx.Lock()
@@ -271,10 +271,10 @@
return true
}
-// deleteByHashWithLabels removes the metric from the hash bucket h. If there
+// removeByHashWithLabels removes the metric from the hash bucket h. If there
// are multiple matches in the bucket, use lvs to select a metric and remove
// only that metric.
-func (m *metricMap) deleteByHashWithLabels(
+func (m *metricMap) removeByHashWithLabels(
h uint64, labels Labels, curry []curriedLabelValue,
) bool {
m.mtx.Lock()
diff --git a/prometheus/vec_test.go b/prometheus/vec_test.go
index bd18a9f..a01a4fd 100644
--- a/prometheus/vec_test.go
+++ b/prometheus/vec_test.go
@@ -20,7 +20,7 @@
dto "github.com/prometheus/client_model/go"
)
-func TestDelete(t *testing.T) {
+func TestRemove(t *testing.T) {
vec := NewGaugeVec(
GaugeOpts{
Name: "test",
@@ -28,10 +28,10 @@
},
[]string{"l1", "l2"},
)
- testDelete(t, vec)
+ testRemove(t, vec)
}
-func TestDeleteWithCollisions(t *testing.T) {
+func TestRemoveWithCollisions(t *testing.T) {
vec := NewGaugeVec(
GaugeOpts{
Name: "test",
@@ -41,40 +41,40 @@
)
vec.hashAdd = func(h uint64, s string) uint64 { return 1 }
vec.hashAddByte = func(h uint64, b byte) uint64 { return 1 }
- testDelete(t, vec)
+ testRemove(t, vec)
}
-func testDelete(t *testing.T, vec *GaugeVec) {
- if got, want := vec.Delete(Labels{"l1": "v1", "l2": "v2"}), false; got != want {
+func testRemove(t *testing.T, vec *GaugeVec) {
+ if got, want := vec.Remove(Labels{"l1": "v1", "l2": "v2"}), false; got != want {
t.Errorf("got %v, want %v", got, want)
}
vec.With(Labels{"l1": "v1", "l2": "v2"}).(Gauge).Set(42)
- if got, want := vec.Delete(Labels{"l1": "v1", "l2": "v2"}), true; got != want {
+ if got, want := vec.Remove(Labels{"l1": "v1", "l2": "v2"}), true; got != want {
t.Errorf("got %v, want %v", got, want)
}
- if got, want := vec.Delete(Labels{"l1": "v1", "l2": "v2"}), false; got != want {
+ if got, want := vec.Remove(Labels{"l1": "v1", "l2": "v2"}), false; got != want {
t.Errorf("got %v, want %v", got, want)
}
vec.With(Labels{"l1": "v1", "l2": "v2"}).(Gauge).Set(42)
- if got, want := vec.Delete(Labels{"l2": "v2", "l1": "v1"}), true; got != want {
+ if got, want := vec.Remove(Labels{"l2": "v2", "l1": "v1"}), true; got != want {
t.Errorf("got %v, want %v", got, want)
}
- if got, want := vec.Delete(Labels{"l2": "v2", "l1": "v1"}), false; got != want {
+ if got, want := vec.Remove(Labels{"l2": "v2", "l1": "v1"}), false; got != want {
t.Errorf("got %v, want %v", got, want)
}
vec.With(Labels{"l1": "v1", "l2": "v2"}).(Gauge).Set(42)
- if got, want := vec.Delete(Labels{"l2": "v1", "l1": "v2"}), false; got != want {
+ if got, want := vec.Remove(Labels{"l2": "v1", "l1": "v2"}), false; got != want {
t.Errorf("got %v, want %v", got, want)
}
- if got, want := vec.Delete(Labels{"l1": "v1"}), false; got != want {
+ if got, want := vec.Remove(Labels{"l1": "v1"}), false; got != want {
t.Errorf("got %v, want %v", got, want)
}
}
-func TestDeleteLabelValues(t *testing.T) {
+func TestRemoveLabelValues(t *testing.T) {
vec := NewGaugeVec(
GaugeOpts{
Name: "test",
@@ -82,10 +82,10 @@
},
[]string{"l1", "l2"},
)
- testDeleteLabelValues(t, vec)
+ testRemoveLabelValues(t, vec)
}
-func TestDeleteLabelValuesWithCollisions(t *testing.T) {
+func TestRemoveLabelValuesWithCollisions(t *testing.T) {
vec := NewGaugeVec(
GaugeOpts{
Name: "test",
@@ -95,32 +95,32 @@
)
vec.hashAdd = func(h uint64, s string) uint64 { return 1 }
vec.hashAddByte = func(h uint64, b byte) uint64 { return 1 }
- testDeleteLabelValues(t, vec)
+ testRemoveLabelValues(t, vec)
}
-func testDeleteLabelValues(t *testing.T, vec *GaugeVec) {
- if got, want := vec.DeleteLabelValues("v1", "v2"), false; got != want {
+func testRemoveLabelValues(t *testing.T, vec *GaugeVec) {
+ if got, want := vec.RemoveLabelValues("v1", "v2"), false; got != want {
t.Errorf("got %v, want %v", got, want)
}
vec.With(Labels{"l1": "v1", "l2": "v2"}).(Gauge).Set(42)
vec.With(Labels{"l1": "v1", "l2": "v3"}).(Gauge).Set(42) // Add junk data for collision.
- if got, want := vec.DeleteLabelValues("v1", "v2"), true; got != want {
+ if got, want := vec.RemoveLabelValues("v1", "v2"), true; got != want {
t.Errorf("got %v, want %v", got, want)
}
- if got, want := vec.DeleteLabelValues("v1", "v2"), false; got != want {
+ if got, want := vec.RemoveLabelValues("v1", "v2"), false; got != want {
t.Errorf("got %v, want %v", got, want)
}
- if got, want := vec.DeleteLabelValues("v1", "v3"), true; got != want {
+ if got, want := vec.RemoveLabelValues("v1", "v3"), true; got != want {
t.Errorf("got %v, want %v", got, want)
}
vec.With(Labels{"l1": "v1", "l2": "v2"}).(Gauge).Set(42)
- // Delete out of order.
- if got, want := vec.DeleteLabelValues("v2", "v1"), false; got != want {
+ // Remove out of order.
+ if got, want := vec.RemoveLabelValues("v2", "v1"), false; got != want {
t.Errorf("got %v, want %v", got, want)
}
- if got, want := vec.DeleteLabelValues("v1"), false; got != want {
+ if got, want := vec.RemoveLabelValues("v1"), false; got != want {
t.Errorf("got %v, want %v", got, want)
}
}
@@ -150,7 +150,7 @@
}
func testMetricVec(t *testing.T, vec *GaugeVec) {
- vec.Reset() // Actually test Reset now!
+ vec.Clear() // Actually test Clear now!
var pair [2]string
// Keep track of metrics.
@@ -199,7 +199,7 @@
t.Fatalf("unexpected number of metrics: %v != %v", total, len(expected))
}
- vec.Reset()
+ vec.Clear()
if len(vec.metricMap.metrics) > 0 {
t.Fatalf("reset failed")
@@ -305,10 +305,10 @@
c1.WithLabelValues("1", "2", "3").Inc()
c2.With(Labels{"one": "11", "two": "22", "three": "33"}).Inc()
assertMetrics(t)
- if !c1.Delete(Labels{"one": "1", "two": "2", "three": "3"}) {
+ if !c1.Remove(Labels{"one": "1", "two": "2", "three": "3"}) {
t.Error("deletion failed")
}
- if !c2.DeleteLabelValues("11", "22", "33") {
+ if !c2.RemoveLabelValues("11", "22", "33") {
t.Error("deletion failed")
}
assertNoMetric(t)
@@ -319,16 +319,16 @@
c1.WithLabelValues("2", "3").Inc()
c2.With(Labels{"two": "22", "three": "33"}).Inc()
assertMetrics(t)
- if c1.Delete(Labels{"two": "22", "three": "33"}) {
+ if c1.Remove(Labels{"two": "22", "three": "33"}) {
t.Error("deletion unexpectedly succeeded")
}
- if c2.DeleteLabelValues("2", "3") {
+ if c2.RemoveLabelValues("2", "3") {
t.Error("deletion unexpectedly succeeded")
}
- if !c1.Delete(Labels{"two": "2", "three": "3"}) {
+ if !c1.Remove(Labels{"two": "2", "three": "3"}) {
t.Error("deletion failed")
}
- if !c2.DeleteLabelValues("22", "33") {
+ if !c2.RemoveLabelValues("22", "33") {
t.Error("deletion failed")
}
assertNoMetric(t)
@@ -339,16 +339,16 @@
c1.WithLabelValues("1", "3").Inc()
c2.With(Labels{"one": "11", "three": "33"}).Inc()
assertMetrics(t)
- if c1.Delete(Labels{"one": "11", "three": "33"}) {
+ if c1.Remove(Labels{"one": "11", "three": "33"}) {
t.Error("deletion unexpectedly succeeded")
}
- if c2.DeleteLabelValues("1", "3") {
+ if c2.RemoveLabelValues("1", "3") {
t.Error("deletion unexpectedly succeeded")
}
- if !c1.Delete(Labels{"one": "1", "three": "3"}) {
+ if !c1.Remove(Labels{"one": "1", "three": "3"}) {
t.Error("deletion failed")
}
- if !c2.DeleteLabelValues("11", "33") {
+ if !c2.RemoveLabelValues("11", "33") {
t.Error("deletion failed")
}
assertNoMetric(t)
@@ -359,16 +359,16 @@
c1.WithLabelValues("1", "2").Inc()
c2.With(Labels{"one": "11", "two": "22"}).Inc()
assertMetrics(t)
- if c1.Delete(Labels{"two": "22", "one": "11"}) {
+ if c1.Remove(Labels{"two": "22", "one": "11"}) {
t.Error("deletion unexpectedly succeeded")
}
- if c2.DeleteLabelValues("1", "2") {
+ if c2.RemoveLabelValues("1", "2") {
t.Error("deletion unexpectedly succeeded")
}
- if !c1.Delete(Labels{"two": "2", "one": "1"}) {
+ if !c1.Remove(Labels{"two": "2", "one": "1"}) {
t.Error("deletion failed")
}
- if !c2.DeleteLabelValues("11", "22") {
+ if !c2.RemoveLabelValues("11", "22") {
t.Error("deletion failed")
}
assertNoMetric(t)
@@ -379,16 +379,16 @@
c1.WithLabelValues("2").Inc()
c2.With(Labels{"two": "22"}).Inc()
assertMetrics(t)
- if c1.Delete(Labels{"two": "22"}) {
+ if c1.Remove(Labels{"two": "22"}) {
t.Error("deletion unexpectedly succeeded")
}
- if c2.DeleteLabelValues("2") {
+ if c2.RemoveLabelValues("2") {
t.Error("deletion unexpectedly succeeded")
}
- if !c1.Delete(Labels{"two": "2"}) {
+ if !c1.Remove(Labels{"two": "2"}) {
t.Error("deletion failed")
}
- if !c2.DeleteLabelValues("22") {
+ if !c2.RemoveLabelValues("22") {
t.Error("deletion failed")
}
assertNoMetric(t)
@@ -399,10 +399,10 @@
c1.WithLabelValues().Inc()
c2.With(nil).Inc()
assertMetrics(t)
- if !c1.Delete(Labels{}) {
+ if !c1.Remove(Labels{}) {
t.Error("deletion failed")
}
- if !c2.DeleteLabelValues() {
+ if !c2.RemoveLabelValues() {
t.Error("deletion failed")
}
assertNoMetric(t)
@@ -413,16 +413,16 @@
c1.WithLabelValues("2").Inc()
c2.With(Labels{"two": "22"}).Inc()
assertMetrics(t)
- if c1.Delete(Labels{"two": "22"}) {
+ if c1.Remove(Labels{"two": "22"}) {
t.Error("deletion unexpectedly succeeded")
}
- if c2.DeleteLabelValues("2") {
+ if c2.RemoveLabelValues("2") {
t.Error("deletion unexpectedly succeeded")
}
- if !c1.Delete(Labels{"two": "2"}) {
+ if !c1.Remove(Labels{"two": "2"}) {
t.Error("deletion failed")
}
- if !c2.DeleteLabelValues("22") {
+ if !c2.RemoveLabelValues("22") {
t.Error("deletion failed")
}
assertNoMetric(t)
@@ -437,10 +437,10 @@
}
assertNoMetric(t)
c1.WithLabelValues("1", "2").Inc()
- if c1.Delete(Labels{"one": "1", "two": "2", "three": "3"}) {
+ if c1.Remove(Labels{"one": "1", "two": "2", "three": "3"}) {
t.Error("deletion unexpectedly succeeded")
}
- if !c1.Delete(Labels{"one": "1", "two": "2"}) {
+ if !c1.Remove(Labels{"one": "1", "two": "2"}) {
t.Error("deletion failed")
}
assertNoMetric(t)