vendor: update github.com/VictoriaMetrics/metrics from v1.12.2 to v1.12.3

This commit is contained in:
Aliaksandr Valialkin 2020-08-07 13:02:25 +03:00
parent 84fd8af6d3
commit 807c2b076c
5 changed files with 44 additions and 28 deletions

2
go.mod
View file

@ -7,7 +7,7 @@ require (
// Do not use the original github.com/valyala/fasthttp because of issues // Do not use the original github.com/valyala/fasthttp because of issues
// like https://github.com/valyala/fasthttp/commit/996610f021ff45fdc98c2ce7884d5fa4e7f9199b // like https://github.com/valyala/fasthttp/commit/996610f021ff45fdc98c2ce7884d5fa4e7f9199b
github.com/VictoriaMetrics/fasthttp v1.0.4 github.com/VictoriaMetrics/fasthttp v1.0.4
github.com/VictoriaMetrics/metrics v1.12.2 github.com/VictoriaMetrics/metrics v1.12.3
github.com/VictoriaMetrics/metricsql v0.4.1 github.com/VictoriaMetrics/metricsql v0.4.1
github.com/aws/aws-sdk-go v1.33.19 github.com/aws/aws-sdk-go v1.33.19
github.com/cespare/xxhash/v2 v2.1.1 github.com/cespare/xxhash/v2 v2.1.1

2
go.sum
View file

@ -51,6 +51,8 @@ github.com/VictoriaMetrics/fasthttp v1.0.4 h1:Aw6UqmPc0v5PunYOpiiyf4hk5B9PTMswdT
github.com/VictoriaMetrics/fasthttp v1.0.4/go.mod h1:m5wCmg1dJN6s1B/lp8/dcKrnnM2l3DWB2eAGZGCTK3g= github.com/VictoriaMetrics/fasthttp v1.0.4/go.mod h1:m5wCmg1dJN6s1B/lp8/dcKrnnM2l3DWB2eAGZGCTK3g=
github.com/VictoriaMetrics/metrics v1.12.2 h1:SG8iAmqavDNuh7GIdHPoGHUhDL23KeKfvSZSozucNeA= github.com/VictoriaMetrics/metrics v1.12.2 h1:SG8iAmqavDNuh7GIdHPoGHUhDL23KeKfvSZSozucNeA=
github.com/VictoriaMetrics/metrics v1.12.2/go.mod h1:Z1tSfPfngDn12bTfZSCqArT3OPY3u88J12hSoOhuiRE= github.com/VictoriaMetrics/metrics v1.12.2/go.mod h1:Z1tSfPfngDn12bTfZSCqArT3OPY3u88J12hSoOhuiRE=
github.com/VictoriaMetrics/metrics v1.12.3 h1:Fe6JHC6MSEKa+BtLhPN8WIvS+HKPzMc2evEpNeCGy7I=
github.com/VictoriaMetrics/metrics v1.12.3/go.mod h1:Z1tSfPfngDn12bTfZSCqArT3OPY3u88J12hSoOhuiRE=
github.com/VictoriaMetrics/metricsql v0.4.1 h1:WbVIfRNCK7HjrzayrpAl07mkh4kiDFZuECsh57rly2Q= github.com/VictoriaMetrics/metricsql v0.4.1 h1:WbVIfRNCK7HjrzayrpAl07mkh4kiDFZuECsh57rly2Q=
github.com/VictoriaMetrics/metricsql v0.4.1/go.mod h1:ylO7YITho/Iw6P71oEaGyHbO94bGoGtzWfLGqFhMIg8= github.com/VictoriaMetrics/metricsql v0.4.1/go.mod h1:ylO7YITho/Iw6P71oEaGyHbO94bGoGtzWfLGqFhMIg8=
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 h1:eMwmnE/GDgah4HI848JfFxHt+iPb26b4zyfspmqY0/8=

View file

@ -324,13 +324,20 @@ func (s *Set) NewSummary(name string) *Summary {
// //
// The returned summary is safe to use from concurrent goroutines. // The returned summary is safe to use from concurrent goroutines.
func (s *Set) NewSummaryExt(name string, window time.Duration, quantiles []float64) *Summary { func (s *Set) NewSummaryExt(name string, window time.Duration, quantiles []float64) *Summary {
if err := validateMetric(name); err != nil {
panic(fmt.Errorf("BUG: invalid metric name %q: %s", name, err))
}
sm := newSummary(window, quantiles) sm := newSummary(window, quantiles)
s.registerMetric(name, sm)
registerSummary(sm)
s.registerSummaryQuantiles(name, sm)
s.mu.Lock() s.mu.Lock()
// defer will unlock in case of panic
// checks in tests
defer s.mu.Unlock()
s.mustRegisterLocked(name, sm)
registerSummaryLocked(sm)
s.registerSummaryQuantilesLocked(name, sm)
s.summaries = append(s.summaries, sm) s.summaries = append(s.summaries, sm)
s.mu.Unlock()
return sm return sm
} }
@ -379,21 +386,17 @@ func (s *Set) GetOrCreateSummaryExt(name string, window time.Duration, quantiles
name: name, name: name,
metric: sm, metric: sm,
} }
mustRegisterQuantiles := false
s.mu.Lock() s.mu.Lock()
nm = s.m[name] nm = s.m[name]
if nm == nil { if nm == nil {
nm = nmNew nm = nmNew
s.m[name] = nm s.m[name] = nm
s.a = append(s.a, nm) s.a = append(s.a, nm)
registerSummary(sm) registerSummaryLocked(sm)
mustRegisterQuantiles = true s.registerSummaryQuantilesLocked(name, sm)
} }
s.summaries = append(s.summaries, sm) s.summaries = append(s.summaries, sm)
s.mu.Unlock() s.mu.Unlock()
if mustRegisterQuantiles {
s.registerSummaryQuantiles(name, sm)
}
} }
sm, ok := nm.metric.(*Summary) sm, ok := nm.metric.(*Summary)
if !ok { if !ok {
@ -408,14 +411,14 @@ func (s *Set) GetOrCreateSummaryExt(name string, window time.Duration, quantiles
return sm return sm
} }
func (s *Set) registerSummaryQuantiles(name string, sm *Summary) { func (s *Set) registerSummaryQuantilesLocked(name string, sm *Summary) {
for i, q := range sm.quantiles { for i, q := range sm.quantiles {
quantileValueName := addTag(name, fmt.Sprintf(`quantile="%g"`, q)) quantileValueName := addTag(name, fmt.Sprintf(`quantile="%g"`, q))
qv := &quantileValue{ qv := &quantileValue{
sm: sm, sm: sm,
idx: i, idx: i,
} }
s.registerMetric(quantileValueName, qv) s.mustRegisterLocked(quantileValueName, qv)
} }
} }
@ -424,6 +427,16 @@ func (s *Set) registerMetric(name string, m metric) {
panic(fmt.Errorf("BUG: invalid metric name %q: %s", name, err)) panic(fmt.Errorf("BUG: invalid metric name %q: %s", name, err))
} }
s.mu.Lock() s.mu.Lock()
// defer will unlock in case of panic
// checks in test
defer s.mu.Unlock()
s.mustRegisterLocked(name, m)
}
// mustRegisterLocked registers given metric with
// the given name. Panics if the given name was
// already registered before.
func (s *Set) mustRegisterLocked(name string, m metric) {
nm, ok := s.m[name] nm, ok := s.m[name]
if !ok { if !ok {
nm = &namedMetric{ nm = &namedMetric{
@ -433,7 +446,6 @@ func (s *Set) registerMetric(name string, m metric) {
s.m[name] = nm s.m[name] = nm
s.a = append(s.a, nm) s.a = append(s.a, nm)
} }
s.mu.Unlock()
if ok { if ok {
panic(fmt.Errorf("BUG: metric %q is already registered", name)) panic(fmt.Errorf("BUG: metric %q is already registered", name))
} }
@ -455,32 +467,34 @@ func (s *Set) UnregisterMetric(name string) bool {
delete(s.m, name) delete(s.m, name)
// remove metric from s.a deleteFromList := func(metricName string) {
found := false for i, nm := range s.a {
for i, nm := range s.a { if nm.name == metricName {
if nm.name == name { s.a = append(s.a[:i], s.a[i+1:]...)
s.a = append(s.a[:i], s.a[i+1:]...) return
found = true }
break
} }
}
if !found {
panic(fmt.Errorf("BUG: cannot find metric %q in the list of registered metrics", name)) panic(fmt.Errorf("BUG: cannot find metric %q in the list of registered metrics", name))
} }
// remove metric from s.a
deleteFromList(name)
sm, ok := m.(*Summary) sm, ok := m.(*Summary)
if !ok { if !ok {
// There is no need in cleaning up s.summaries. // There is no need in cleaning up summary.
return true return true
} }
// Remove summary metric name including quantile labels from set // cleanup registry from per-quantile metrics
for _, q := range sm.quantiles { for _, q := range sm.quantiles {
quantileValueName := addTag(name, fmt.Sprintf(`quantile="%g"`, q)) quantileValueName := addTag(name, fmt.Sprintf(`quantile="%g"`, q))
delete(s.m, quantileValueName) delete(s.m, quantileValueName)
deleteFromList(quantileValueName)
} }
// Remove sm from s.summaries // Remove sm from s.summaries
found = false found := false
for i, xsm := range s.summaries { for i, xsm := range s.summaries {
if xsm == sm { if xsm == sm {
s.summaries = append(s.summaries[:i], s.summaries[i+1:]...) s.summaries = append(s.summaries[:i], s.summaries[i+1:]...)

View file

@ -203,7 +203,7 @@ func addTag(name, tag string) string {
return fmt.Sprintf("%s,%s}", name[:len(name)-1], tag) return fmt.Sprintf("%s,%s}", name[:len(name)-1], tag)
} }
func registerSummary(sm *Summary) { func registerSummaryLocked(sm *Summary) {
window := sm.window window := sm.window
summariesLock.Lock() summariesLock.Lock()
summaries[window] = append(summaries[window], sm) summaries[window] = append(summaries[window], sm)

2
vendor/modules.txt vendored
View file

@ -14,7 +14,7 @@ github.com/VictoriaMetrics/fastcache
github.com/VictoriaMetrics/fasthttp github.com/VictoriaMetrics/fasthttp
github.com/VictoriaMetrics/fasthttp/fasthttputil github.com/VictoriaMetrics/fasthttp/fasthttputil
github.com/VictoriaMetrics/fasthttp/stackless github.com/VictoriaMetrics/fasthttp/stackless
# github.com/VictoriaMetrics/metrics v1.12.2 # github.com/VictoriaMetrics/metrics v1.12.3
github.com/VictoriaMetrics/metrics github.com/VictoriaMetrics/metrics
# github.com/VictoriaMetrics/metricsql v0.4.1 # github.com/VictoriaMetrics/metricsql v0.4.1
github.com/VictoriaMetrics/metricsql github.com/VictoriaMetrics/metricsql