From e8998c69a78913a1365ae6f89445e6037f962136 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Fri, 28 Jun 2019 14:04:28 +0300 Subject: [PATCH] vendor: update github.com/VictoriaMetrics/metrics to v1.6.1 --- go.mod | 2 +- go.sum | 4 ++-- .../VictoriaMetrics/metrics/README.md | 1 + .../github.com/VictoriaMetrics/metrics/set.go | 14 +++++++++++--- .../VictoriaMetrics/metrics/summary.go | 18 ++++++++++++++++-- vendor/modules.txt | 2 +- 6 files changed, 32 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index c29f8b2e3..3e98ee11a 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index 45cf5dd78..923c274bc 100644 --- a/go.sum +++ b/go.sum @@ -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= diff --git a/vendor/github.com/VictoriaMetrics/metrics/README.md b/vendor/github.com/VictoriaMetrics/metrics/README.md index ab3885c51..1b4a43e14 100644 --- a/vendor/github.com/VictoriaMetrics/metrics/README.md +++ b/vendor/github.com/VictoriaMetrics/metrics/README.md @@ -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 diff --git a/vendor/github.com/VictoriaMetrics/metrics/set.go b/vendor/github.com/VictoriaMetrics/metrics/set.go index 293a46bb6..33a39a0b5 100644 --- a/vendor/github.com/VictoriaMetrics/metrics/set.go +++ b/vendor/github.com/VictoriaMetrics/metrics/set.go @@ -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) diff --git a/vendor/github.com/VictoriaMetrics/metrics/summary.go b/vendor/github.com/VictoriaMetrics/metrics/summary.go index 7075aab6f..3bb002dc7 100644 --- a/vendor/github.com/VictoriaMetrics/metrics/summary.go +++ b/vendor/github.com/VictoriaMetrics/metrics/summary.go @@ -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() { diff --git a/vendor/modules.txt b/vendor/modules.txt index 7dd6a4b4a..e2fb8b7c2 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -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