This commit is contained in:
parent
6a144d3619
commit
dd0c59c0d6
6
set.go
6
set.go
@ -473,6 +473,12 @@ func (s *Set) UnregisterMetric(name string) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// Remove summary metric name including quantile labels from set
|
||||
for _, q := range sm.quantiles {
|
||||
quantileValueName := addTag(name, fmt.Sprintf(`quantile="%g"`, q))
|
||||
delete(s.m, quantileValueName)
|
||||
}
|
||||
|
||||
// Remove sm from s.summaries
|
||||
found = false
|
||||
for i, xsm := range s.summaries {
|
||||
|
@ -88,13 +88,19 @@ func TestSetUnregisterMetric(t *testing.T) {
|
||||
}
|
||||
|
||||
// Validate metrics are removed
|
||||
const cName, smName = "counter_1", "summary_1"
|
||||
ok := false
|
||||
for _, n := range s.ListMetricNames() {
|
||||
if n == "counter_1" || n == "summary_1" {
|
||||
if n == cName || n == smName {
|
||||
ok = true
|
||||
}
|
||||
}
|
||||
if ok {
|
||||
t.Fatalf("Metric counter_1 and summary_1 must not be listed anymore after unregister")
|
||||
}
|
||||
|
||||
// re-register with the same names supposed
|
||||
// to be successful
|
||||
s.NewCounter(cName).Inc()
|
||||
s.NewSummary(smName).Update(float64(1))
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user