mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
vendor: update github.com/VictoriaMetrics/metrics from v1.8.2 to v1.8.3
This commit is contained in:
parent
d24fc87a6f
commit
e70f543321
5 changed files with 80 additions and 17 deletions
2
go.mod
2
go.mod
|
@ -4,7 +4,7 @@ require (
|
||||||
cloud.google.com/go v0.49.0 // indirect
|
cloud.google.com/go v0.49.0 // indirect
|
||||||
cloud.google.com/go/storage v1.4.0
|
cloud.google.com/go/storage v1.4.0
|
||||||
github.com/VictoriaMetrics/fastcache v1.5.2
|
github.com/VictoriaMetrics/fastcache v1.5.2
|
||||||
github.com/VictoriaMetrics/metrics v1.8.2
|
github.com/VictoriaMetrics/metrics v1.8.3
|
||||||
github.com/aws/aws-sdk-go v1.25.37
|
github.com/aws/aws-sdk-go v1.25.37
|
||||||
github.com/cespare/xxhash/v2 v2.1.1
|
github.com/cespare/xxhash/v2 v2.1.1
|
||||||
github.com/golang/groupcache v0.0.0-20191027212112-611e8accdfc9 // indirect
|
github.com/golang/groupcache v0.0.0-20191027212112-611e8accdfc9 // indirect
|
||||||
|
|
4
go.sum
4
go.sum
|
@ -24,8 +24,8 @@ github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAE
|
||||||
github.com/OneOfOne/xxhash v1.2.5/go.mod h1:eZbhyaAYD41SGSSsnmcpxVoRiQ/MPUTjUdIIOT9Um7Q=
|
github.com/OneOfOne/xxhash v1.2.5/go.mod h1:eZbhyaAYD41SGSSsnmcpxVoRiQ/MPUTjUdIIOT9Um7Q=
|
||||||
github.com/VictoriaMetrics/fastcache v1.5.2 h1:Erd8iIuBAL9kke8JzM4+WxkKuFkHh3ktwLanJvDgR44=
|
github.com/VictoriaMetrics/fastcache v1.5.2 h1:Erd8iIuBAL9kke8JzM4+WxkKuFkHh3ktwLanJvDgR44=
|
||||||
github.com/VictoriaMetrics/fastcache v1.5.2/go.mod h1:+jv9Ckb+za/P1ZRg/sulP5Ni1v49daAVERr0H3CuscE=
|
github.com/VictoriaMetrics/fastcache v1.5.2/go.mod h1:+jv9Ckb+za/P1ZRg/sulP5Ni1v49daAVERr0H3CuscE=
|
||||||
github.com/VictoriaMetrics/metrics v1.8.2 h1:Oa+u0XlcofYfPDAPTgKObyangxbp+vVGkjSwARtObFQ=
|
github.com/VictoriaMetrics/metrics v1.8.3 h1:5eVP1tVjnSao/YVMIQiWrQkEJ6nzQq7IANbNniVu4cI=
|
||||||
github.com/VictoriaMetrics/metrics v1.8.2/go.mod h1:LU2j9qq7xqZYXz8tF3/RQnB2z2MbZms5TDiIg9/NHiQ=
|
github.com/VictoriaMetrics/metrics v1.8.3/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 h1:eMwmnE/GDgah4HI848JfFxHt+iPb26b4zyfspmqY0/8=
|
||||||
github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM=
|
github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM=
|
||||||
github.com/aws/aws-sdk-go v1.25.37 h1:gBtB/F3dophWpsUQKN/Kni+JzYEH2mGHF4hWNtfED1w=
|
github.com/aws/aws-sdk-go v1.25.37 h1:gBtB/F3dophWpsUQKN/Kni+JzYEH2mGHF4hWNtfED1w=
|
||||||
|
|
15
vendor/github.com/VictoriaMetrics/metrics/README.md
generated
vendored
15
vendor/github.com/VictoriaMetrics/metrics/README.md
generated
vendored
|
@ -14,6 +14,7 @@
|
||||||
* Easy to use. See the [API docs](http://godoc.org/github.com/VictoriaMetrics/metrics).
|
* Easy to use. See the [API docs](http://godoc.org/github.com/VictoriaMetrics/metrics).
|
||||||
* Fast.
|
* Fast.
|
||||||
* Allows exporting distinct metric sets via distinct endpoints. See [Set](http://godoc.org/github.com/VictoriaMetrics/metrics#Set).
|
* Allows exporting distinct metric sets via distinct endpoints. See [Set](http://godoc.org/github.com/VictoriaMetrics/metrics#Set).
|
||||||
|
* Supports [easy-to-use histograms](http://godoc.org/github.com/VictoriaMetrics/metrics#Histogram), which just work without any tuning.
|
||||||
|
|
||||||
|
|
||||||
### Limitations
|
### Limitations
|
||||||
|
@ -39,6 +40,9 @@ var (
|
||||||
queueSize = metrics.NewGauge(`queue_size{queue="foobar",topic="baz"}`, func() float64 {
|
queueSize = metrics.NewGauge(`queue_size{queue="foobar",topic="baz"}`, func() float64 {
|
||||||
return float64(foobarQueue.Len())
|
return float64(foobarQueue.Len())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Register histogram with a single label.
|
||||||
|
responseSize = metrics.NewHistogram(`response_size{path="/foo/bar"}`)
|
||||||
)
|
)
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
|
@ -50,6 +54,9 @@ func requestHandler() {
|
||||||
processRequest()
|
processRequest()
|
||||||
// Update requestDuration summary.
|
// Update requestDuration summary.
|
||||||
requestDuration.UpdateDuration(startTime)
|
requestDuration.UpdateDuration(startTime)
|
||||||
|
|
||||||
|
// Update responseSize histogram.
|
||||||
|
responseSize.Update(responseSize)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Expose the registered metrics at `/metrics` path.
|
// Expose the registered metrics at `/metrics` path.
|
||||||
|
@ -86,3 +93,11 @@ exposed from your application.
|
||||||
|
|
||||||
Just use [GetOrCreateCounter](http://godoc.org/github.com/VictoriaMetrics/metrics#GetOrCreateCounter)
|
Just use [GetOrCreateCounter](http://godoc.org/github.com/VictoriaMetrics/metrics#GetOrCreateCounter)
|
||||||
instead of `CounterVec.With`. See [this example](https://godoc.org/github.com/VictoriaMetrics/metrics#example-Counter--Vec) for details.
|
instead of `CounterVec.With`. See [this example](https://godoc.org/github.com/VictoriaMetrics/metrics#example-Counter--Vec) for details.
|
||||||
|
|
||||||
|
|
||||||
|
#### Why [Histogram](http://godoc.org/github.com/VictoriaMetrics/metrics#Histogram) buckets contain `vmrange` labels instead of `le` labels like in Prometheus histograms?
|
||||||
|
|
||||||
|
Buckets with `vmrange` labels occupy less disk space comparing to Promethes-style buckets with `le` labels,
|
||||||
|
because `vmrange` buckets don't include counters for the previous ranges. [VictoriaMetrics](https://github.com/VictoriaMetrics/VictoriaMetrics) provides `prometheus_buckets`
|
||||||
|
function, which converts `vmrange` buckets to Prometheus-style buckets with `le` labels. This is useful for building heatmaps in Grafana.
|
||||||
|
Additionally, its' `histogram_quantile` function transparently handles histogram buckets with `vmrange` labels.
|
||||||
|
|
74
vendor/github.com/VictoriaMetrics/metrics/histogram.go
generated
vendored
74
vendor/github.com/VictoriaMetrics/metrics/histogram.go
generated
vendored
|
@ -37,14 +37,16 @@ import (
|
||||||
// - <start> and <end> - start and end values for the given bucket
|
// - <start> and <end> - start and end values for the given bucket
|
||||||
// - <counter> - the number of hits to the given bucket during Update* calls.
|
// - <counter> - the number of hits to the given bucket during Update* calls.
|
||||||
//
|
//
|
||||||
// Only non-zero buckets are exposed.
|
// Histogram buckets can be converted to Prometheus-like buckets with `le` labels
|
||||||
|
// with `prometheus_buckets(<metric_name>_bucket)` function in VictoriaMetrics:
|
||||||
//
|
//
|
||||||
// Histogram buckets can be converted to Prometheus-like buckets in VictoriaMetrics
|
// prometheus_buckets(request_duration_bucket)
|
||||||
// with `prometheus_buckets(<metric_name>_bucket)`:
|
|
||||||
//
|
|
||||||
// prometheus_buckets(rate(request_duration_bucket[5m]))
|
|
||||||
//
|
//
|
||||||
// Histogram cannot be used for negative values.
|
// Histogram cannot be used for negative values.
|
||||||
|
//
|
||||||
|
// Time series produced by the Histogram have better compression ratio comparing to
|
||||||
|
// Prometheus histogram buckets with `le` labels, since they don't include counters
|
||||||
|
// for all the previous buckets.
|
||||||
type Histogram struct {
|
type Histogram struct {
|
||||||
buckets [bucketsCount]uint64
|
buckets [bucketsCount]uint64
|
||||||
|
|
||||||
|
@ -89,6 +91,10 @@ func GetOrCreateHistogram(name string) *Histogram {
|
||||||
//
|
//
|
||||||
// v cannot be negative.
|
// v cannot be negative.
|
||||||
func (h *Histogram) Update(v float64) {
|
func (h *Histogram) Update(v float64) {
|
||||||
|
if math.IsNaN(v) || v < 0 {
|
||||||
|
// Skip NaNs and negative values.
|
||||||
|
return
|
||||||
|
}
|
||||||
idx := getBucketIdx(v)
|
idx := getBucketIdx(v)
|
||||||
if idx >= uint(len(h.buckets)) {
|
if idx >= uint(len(h.buckets)) {
|
||||||
panic(fmt.Errorf("BUG: idx cannot exceed %d; got %d", len(h.buckets), idx))
|
panic(fmt.Errorf("BUG: idx cannot exceed %d; got %d", len(h.buckets), idx))
|
||||||
|
@ -106,13 +112,60 @@ func (h *Histogram) UpdateDuration(startTime time.Time) {
|
||||||
h.Update(d)
|
h.Update(d)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// VisitNonZeroBuckets calls f for all buckets with non-zero counters.
|
||||||
|
func (h *Histogram) VisitNonZeroBuckets(f func(vmrange string, count uint64)) {
|
||||||
|
for i, v := range h.buckets[:] {
|
||||||
|
if v == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
vmrange := getRangeForBucketIdx(uint(i))
|
||||||
|
f(vmrange, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func getRangeForBucketIdx(idx uint) string {
|
||||||
|
bucketRangesOnce.Do(initBucketRanges)
|
||||||
|
return bucketRanges[idx]
|
||||||
|
}
|
||||||
|
|
||||||
|
func initBucketRanges() {
|
||||||
|
start := "0"
|
||||||
|
for i := 0; i < bucketsCount; i++ {
|
||||||
|
end := getRangeEndFromBucketIdx(uint(i))
|
||||||
|
bucketRanges[i] = start + "..." + end
|
||||||
|
start = end
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
bucketRanges [bucketsCount]string
|
||||||
|
bucketRangesOnce sync.Once
|
||||||
|
)
|
||||||
|
|
||||||
|
func getTagForBucketIdx(idx uint) string {
|
||||||
|
bucketTagsOnce.Do(initBucketTags)
|
||||||
|
return bucketTags[idx]
|
||||||
|
}
|
||||||
|
|
||||||
|
func initBucketTags() {
|
||||||
|
for i := 0; i < bucketsCount; i++ {
|
||||||
|
vmrange := getRangeForBucketIdx(uint(i))
|
||||||
|
bucketTags[i] = fmt.Sprintf(`vmrange=%q`, vmrange)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
bucketTags [bucketsCount]string
|
||||||
|
bucketTagsOnce sync.Once
|
||||||
|
)
|
||||||
|
|
||||||
func (h *Histogram) marshalTo(prefix string, w io.Writer) {
|
func (h *Histogram) marshalTo(prefix string, w io.Writer) {
|
||||||
count := atomic.LoadUint64(&h.count)
|
count := atomic.LoadUint64(&h.count)
|
||||||
if count == 0 {
|
if count == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for i := range h.buckets[:] {
|
for i := range h.buckets[:] {
|
||||||
h.marshalBucket(prefix, w, i)
|
h.marshalBucket(prefix, w, uint(i))
|
||||||
}
|
}
|
||||||
// Marshal `_sum` and `_count` metrics.
|
// Marshal `_sum` and `_count` metrics.
|
||||||
name, filters := splitMetricName(prefix)
|
name, filters := splitMetricName(prefix)
|
||||||
|
@ -127,17 +180,12 @@ func (h *Histogram) marshalTo(prefix string, w io.Writer) {
|
||||||
fmt.Fprintf(w, "%s_count%s %d\n", name, filters, count)
|
fmt.Fprintf(w, "%s_count%s %d\n", name, filters, count)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Histogram) marshalBucket(prefix string, w io.Writer, idx int) {
|
func (h *Histogram) marshalBucket(prefix string, w io.Writer, idx uint) {
|
||||||
v := h.buckets[idx]
|
v := h.buckets[idx]
|
||||||
if v == 0 {
|
if v == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
start := "0"
|
tag := getTagForBucketIdx(idx)
|
||||||
if idx > 0 {
|
|
||||||
start = getRangeEndFromBucketIdx(uint(idx - 1))
|
|
||||||
}
|
|
||||||
end := getRangeEndFromBucketIdx(uint(idx))
|
|
||||||
tag := fmt.Sprintf(`vmrange="%s...%s"`, start, end)
|
|
||||||
prefix = addTag(prefix, tag)
|
prefix = addTag(prefix, tag)
|
||||||
name, filters := splitMetricName(prefix)
|
name, filters := splitMetricName(prefix)
|
||||||
fmt.Fprintf(w, "%s_bucket%s %d\n", name, filters, v)
|
fmt.Fprintf(w, "%s_bucket%s %d\n", name, filters, v)
|
||||||
|
|
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
|
@ -12,7 +12,7 @@ cloud.google.com/go/storage
|
||||||
github.com/BurntSushi/toml
|
github.com/BurntSushi/toml
|
||||||
# github.com/VictoriaMetrics/fastcache v1.5.2
|
# github.com/VictoriaMetrics/fastcache v1.5.2
|
||||||
github.com/VictoriaMetrics/fastcache
|
github.com/VictoriaMetrics/fastcache
|
||||||
# github.com/VictoriaMetrics/metrics v1.8.2
|
# github.com/VictoriaMetrics/metrics v1.8.3
|
||||||
github.com/VictoriaMetrics/metrics
|
github.com/VictoriaMetrics/metrics
|
||||||
# github.com/aws/aws-sdk-go v1.25.37
|
# github.com/aws/aws-sdk-go v1.25.37
|
||||||
github.com/aws/aws-sdk-go/aws
|
github.com/aws/aws-sdk-go/aws
|
||||||
|
|
Loading…
Reference in a new issue