vendor: update github.com/VictoriaMetrics/metrics to v1.6.1

This commit is contained in:
Aliaksandr Valialkin 2019-06-28 14:04:28 +03:00
parent 55bcf60ea6
commit e8998c69a7
6 changed files with 32 additions and 9 deletions

2
go.mod
View file

@ -2,7 +2,7 @@ module github.com/VictoriaMetrics/VictoriaMetrics
require (
github.com/VictoriaMetrics/fastcache v1.5.1
github.com/VictoriaMetrics/metrics v1.5.0
github.com/VictoriaMetrics/metrics v1.6.1
github.com/cespare/xxhash/v2 v2.0.1-0.20190104013014-3767db7a7e18
github.com/golang/snappy v0.0.1
github.com/spaolacci/murmur3 v1.1.0 // indirect

4
go.sum
View file

@ -3,8 +3,8 @@ github.com/OneOfOne/xxhash v1.2.5 h1:zl/OfRA6nftbBK9qTohYBJ5xvw6C/oNKizR7cZGl3cI
github.com/OneOfOne/xxhash v1.2.5/go.mod h1:eZbhyaAYD41SGSSsnmcpxVoRiQ/MPUTjUdIIOT9Um7Q=
github.com/VictoriaMetrics/fastcache v1.5.1 h1:qHgHjyoNFV7jgucU8QZUuU4gcdhfs8QW1kw68OD2Lag=
github.com/VictoriaMetrics/fastcache v1.5.1/go.mod h1:+jv9Ckb+za/P1ZRg/sulP5Ni1v49daAVERr0H3CuscE=
github.com/VictoriaMetrics/metrics v1.5.0 h1:WvQqPn+z9pR1U7J58CgaGiWrN8phNGSpr2xUSxJnfpE=
github.com/VictoriaMetrics/metrics v1.5.0/go.mod h1:QZAL5yLaXvhSPeib0ahluGo9VK0HXDZHovKaKlpuWvs=
github.com/VictoriaMetrics/metrics v1.6.1 h1:jHLmdFDuoXJC41FVvYVLoMzRieu7MOxFjYZdPHBN0EQ=
github.com/VictoriaMetrics/metrics v1.6.1/go.mod h1:QZAL5yLaXvhSPeib0ahluGo9VK0HXDZHovKaKlpuWvs=
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/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko=

View file

@ -13,6 +13,7 @@
See [this article](https://medium.com/@valyala/stripping-dependency-bloat-in-victoriametrics-docker-image-983fb5912b0d) for details.
* Easy to use. See the [API docs](http://godoc.org/github.com/VictoriaMetrics/metrics).
* Fast.
* Allows exporting distinct metric sets via distinct endpoints. See [Set](http://godoc.org/github.com/VictoriaMetrics/metrics#Set).
### Limitations

View file

@ -14,9 +14,10 @@ import (
//
// Set.WritePrometheus must be called for exporting metrics from the set.
type Set struct {
mu sync.Mutex
a []*namedMetric
m map[string]*namedMetric
mu sync.Mutex
a []*namedMetric
m map[string]*namedMetric
summaries []*Summary
}
// NewSet creates new set of metrics.
@ -32,6 +33,9 @@ func (s *Set) WritePrometheus(w io.Writer) {
return s.a[i].name < s.a[j].name
}
s.mu.Lock()
for _, sm := range s.summaries {
sm.updateQuantiles()
}
if !sort.SliceIsSorted(s.a, lessFunc) {
sort.Slice(s.a, lessFunc)
}
@ -200,6 +204,9 @@ func (s *Set) NewSummaryExt(name string, window time.Duration, quantiles []float
s.registerMetric(name, sm)
registerSummary(sm)
s.registerSummaryQuantiles(name, sm)
s.mu.Lock()
s.summaries = append(s.summaries, sm)
s.mu.Unlock()
return sm
}
@ -258,6 +265,7 @@ func (s *Set) GetOrCreateSummaryExt(name string, window time.Duration, quantiles
registerSummary(sm)
mustRegisterQuantiles = true
}
s.summaries = append(s.summaries, sm)
s.mu.Unlock()
if mustRegisterQuantiles {
s.registerSummaryQuantiles(name, sm)

View file

@ -24,6 +24,9 @@ type Summary struct {
quantiles []float64
quantileValues []float64
sum float64
count uint64
window time.Duration
}
@ -83,6 +86,8 @@ func (sm *Summary) Update(v float64) {
sm.mu.Lock()
sm.curr.Update(v)
sm.next.Update(v)
sm.sum += v
sm.count++
sm.mu.Unlock()
}
@ -93,9 +98,18 @@ func (sm *Summary) UpdateDuration(startTime time.Time) {
}
func (sm *Summary) marshalTo(prefix string, w io.Writer) {
// Just update sm.quantileValues and don't write anything to w.
// Marshal only *_sum and *_count values.
// Quantile values should be already updated by the caller via sm.updateQuantiles() call.
// sm.quantileValues will be marshaled later via quantileValue.marshalTo.
sm.updateQuantiles()
sm.mu.Lock()
sum := sm.sum
count := sm.count
sm.mu.Unlock()
if count > 0 {
fmt.Fprintf(w, "%s_sum %g\n", prefix, sum)
fmt.Fprintf(w, "%s_count %d\n", prefix, count)
}
}
func (sm *Summary) updateQuantiles() {

2
vendor/modules.txt vendored
View file

@ -1,6 +1,6 @@
# github.com/VictoriaMetrics/fastcache v1.5.1
github.com/VictoriaMetrics/fastcache
# github.com/VictoriaMetrics/metrics v1.5.0
# github.com/VictoriaMetrics/metrics v1.6.1
github.com/VictoriaMetrics/metrics
# github.com/cespare/xxhash/v2 v2.0.1-0.20190104013014-3767db7a7e18
github.com/cespare/xxhash/v2