vendor: update github.com/VictoriaMetrics/metrics from v1.10.1 to v1.11.0

This commit is contained in:
Aliaksandr Valialkin 2020-02-26 20:40:55 +02:00
parent 117c76311c
commit cc5fe0b315
6 changed files with 101 additions and 6 deletions

2
go.mod
View file

@ -4,7 +4,7 @@ require (
cloud.google.com/go v0.53.0 // indirect
cloud.google.com/go/storage v1.5.0
github.com/VictoriaMetrics/fastcache v1.5.7
github.com/VictoriaMetrics/metrics v1.10.1
github.com/VictoriaMetrics/metrics v1.11.0
github.com/aws/aws-sdk-go v1.29.3
github.com/cespare/xxhash/v2 v2.1.1
github.com/golang/snappy v0.0.1

4
go.sum
View file

@ -25,8 +25,8 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/VictoriaMetrics/fastcache v1.5.7 h1:4y6y0G8PRzszQUYIQHHssv/jgPHAb5qQuuDNdCbyAgw=
github.com/VictoriaMetrics/fastcache v1.5.7/go.mod h1:ptDBkNMQI4RtmVo8VS/XwRY6RoTu1dAWCbrk+6WsEM8=
github.com/VictoriaMetrics/metrics v1.10.1 h1:g10gmOvFLKYav0GlVSGbxCek6dSMqMY8MlvO9OkEgEg=
github.com/VictoriaMetrics/metrics v1.10.1/go.mod h1:LU2j9qq7xqZYXz8tF3/RQnB2z2MbZms5TDiIg9/NHiQ=
github.com/VictoriaMetrics/metrics v1.11.0 h1:sfRmbgk7hGrxNXrziwyTmU8FZFLFrPNC7g2kZs0xMTQ=
github.com/VictoriaMetrics/metrics v1.11.0/go.mod h1:LU2j9qq7xqZYXz8tF3/RQnB2z2MbZms5TDiIg9/NHiQ=
github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156 h1:eMwmnE/GDgah4HI848JfFxHt+iPb26b4zyfspmqY0/8=
github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM=
github.com/aws/aws-sdk-go v1.29.3 h1:yvEwt1IvgiWpWWayQBQHCK0knTmHKyI7FCrliOV5Pd8=

View file

@ -41,7 +41,24 @@ var defaultSet = NewSet()
func WritePrometheus(w io.Writer, exposeProcessMetrics bool) {
defaultSet.WritePrometheus(w)
if exposeProcessMetrics {
writeGoMetrics(w)
writeProcessMetrics(w)
WriteProcessMetrics(w)
}
}
// WriteProcessMetrics writes additional process metrics in Prometheus format to w.
//
// Various `go_*` and `process_*` metrics are exposed for the currently
// running process.
//
// The WriteProcessMetrics func is usually called in combination with writing Set metrics
// inside "/metrics" handler:
//
// http.HandleFunc("/metrics", func(w http.ResponseWriter, req *http.Request) {
// mySet.WritePrometheus(w)
// metrics.WriteProcessMetrics(w)
// })
//
func WriteProcessMetrics(w io.Writer) {
writeGoMetrics(w)
writeProcessMetrics(w)
}

View file

@ -438,3 +438,62 @@ func (s *Set) registerMetric(name string, m metric) {
panic(fmt.Errorf("BUG: metric %q is already registered", name))
}
}
// UnregisterMetric removes metric with the given name from s.
//
// True is returned if the metric has been removed.
// False is returned if the given metric is missing in s.
func (s *Set) UnregisterMetric(name string) bool {
s.mu.Lock()
defer s.mu.Unlock()
nm, ok := s.m[name]
if !ok {
return false
}
m := nm.metric
delete(s.m, name)
// remove metric from s.a
found := false
for i, nm := range s.a {
if nm.name == name {
s.a = append(s.a[:i], s.a[i+1:]...)
found = true
break
}
}
if !found {
panic(fmt.Errorf("BUG: cannot find metric %q in the list of registered metrics", name))
}
sm, ok := m.(*Summary)
if !ok {
// There is no need in cleaning up s.summaries.
return true
}
// Remove sm from s.summaries
found = false
for i, xsm := range s.summaries {
if xsm == sm {
s.summaries = append(s.summaries[:i], s.summaries[i+1:]...)
found = true
break
}
}
if !found {
panic(fmt.Errorf("BUG: cannot find summary %q in the list of registered summaries", name))
}
unregisterSummary(sm)
return true
}
// ListMetricNames returns a list of all the metrics in s.
func (s *Set) ListMetricNames() []string {
var list []string
for name := range s.m {
list = append(list, name)
}
return list
}

View file

@ -213,6 +213,25 @@ func registerSummary(sm *Summary) {
summariesLock.Unlock()
}
func unregisterSummary(sm *Summary) {
window := sm.window
summariesLock.Lock()
sms := summaries[window]
found := false
for i, xsm := range sms {
if xsm == sm {
sms = append(sms[:i], sms[i+1:]...)
found = true
break
}
}
if !found {
panic(fmt.Errorf("BUG: cannot find registered summary %p", sm))
}
summaries[window] = sms
summariesLock.Unlock()
}
func summariesSwapCron(window time.Duration) {
for {
time.Sleep(window / 2)

2
vendor/modules.txt vendored
View file

@ -12,7 +12,7 @@ cloud.google.com/go/storage
github.com/BurntSushi/toml
# github.com/VictoriaMetrics/fastcache v1.5.7
github.com/VictoriaMetrics/fastcache
# github.com/VictoriaMetrics/metrics v1.10.1
# github.com/VictoriaMetrics/metrics v1.11.0
github.com/VictoriaMetrics/metrics
# github.com/aws/aws-sdk-go v1.29.3
github.com/aws/aws-sdk-go/aws