mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
upgrade go metrics to 0.3.4 (#8637)
This commit is contained in:
2
go.mod
2
go.mod
@@ -23,7 +23,7 @@ require (
|
||||
github.com/NVIDIA/gpu-monitoring-tools v0.0.0-20180829222009-86f2a9fac6c5
|
||||
github.com/NYTimes/gziphandler v1.0.1
|
||||
github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e
|
||||
github.com/armon/go-metrics v0.3.3
|
||||
github.com/armon/go-metrics v0.3.4
|
||||
github.com/aws/aws-sdk-go v1.25.41
|
||||
github.com/boltdb/bolt v1.3.1
|
||||
github.com/checkpoint-restore/go-criu v0.0.0-20190109184317-bdb7599cd87b // indirect
|
||||
|
||||
4
go.sum
4
go.sum
@@ -76,8 +76,8 @@ github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e h1:QEF07wC0T1rKkctt1
|
||||
github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=
|
||||
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY=
|
||||
github.com/armon/go-metrics v0.0.0-20190430140413-ec5e00d3c878/go.mod h1:3AMJUQhVx52RsWOnlkpikZr01T/yAVN2gn0861vByNg=
|
||||
github.com/armon/go-metrics v0.3.3 h1:a9F4rlj7EWWrbj7BYw8J8+x+ZZkJeqzNyRk8hdPF+ro=
|
||||
github.com/armon/go-metrics v0.3.3/go.mod h1:4O98XIr/9W0sxpJ8UaYkvjk10Iff7SnFrb4QAOwNTFc=
|
||||
github.com/armon/go-metrics v0.3.4 h1:Xqf+7f2Vhl9tsqDYmXhnXInUdcrtgpRNpIA15/uldSc=
|
||||
github.com/armon/go-metrics v0.3.4/go.mod h1:4O98XIr/9W0sxpJ8UaYkvjk10Iff7SnFrb4QAOwNTFc=
|
||||
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
|
||||
github.com/armon/go-radix v1.0.0 h1:F4z6KzEeeQIMeLFa97iZU6vupzoecKdU5TX24SNppXI=
|
||||
github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
|
||||
|
||||
@@ -38,8 +38,6 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
|
||||
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
|
||||
github.com/elazarl/go-bindata-assetfs v1.0.1-0.20200509193318-234c15e7648f h1:AwZUiMWfYSmIiHdFJIubTSs8BFIFoMmUFbeuwBzHIPs=
|
||||
github.com/elazarl/go-bindata-assetfs v1.0.1-0.20200509193318-234c15e7648f/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4=
|
||||
github.com/elazarl/go-bindata-assetfs v1.0.1 h1:m0kkaHRKEu7tUIUFVwhGGGYClXvyl4RE03qmvRTNfbw=
|
||||
github.com/elazarl/go-bindata-assetfs v1.0.1/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4=
|
||||
github.com/fatih/color v1.6.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
|
||||
|
||||
2
vendor/github.com/armon/go-metrics/.gitignore
generated
vendored
2
vendor/github.com/armon/go-metrics/.gitignore
generated
vendored
@@ -22,3 +22,5 @@ _testmain.go
|
||||
*.exe
|
||||
|
||||
/metrics.out
|
||||
|
||||
.idea
|
||||
|
||||
127
vendor/github.com/armon/go-metrics/prometheus/prometheus.go
generated
vendored
127
vendor/github.com/armon/go-metrics/prometheus/prometheus.go
generated
vendored
@@ -5,12 +5,11 @@ package prometheus
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"regexp"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"regexp"
|
||||
|
||||
"github.com/armon/go-metrics"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/client_golang/prometheus/push"
|
||||
@@ -36,10 +35,24 @@ type PrometheusSink struct {
|
||||
gauges sync.Map
|
||||
summaries sync.Map
|
||||
counters sync.Map
|
||||
updates sync.Map
|
||||
expiration time.Duration
|
||||
}
|
||||
|
||||
type PrometheusGauge struct {
|
||||
prometheus.Gauge
|
||||
updatedAt time.Time
|
||||
}
|
||||
|
||||
type PrometheusSummary struct {
|
||||
prometheus.Summary
|
||||
updatedAt time.Time
|
||||
}
|
||||
|
||||
type PrometheusCounter struct {
|
||||
prometheus.Counter
|
||||
updatedAt time.Time
|
||||
}
|
||||
|
||||
// NewPrometheusSink creates a new PrometheusSink using the default options.
|
||||
func NewPrometheusSink() (*PrometheusSink, error) {
|
||||
return NewPrometheusSinkFrom(DefaultPrometheusOpts)
|
||||
@@ -51,7 +64,6 @@ func NewPrometheusSinkFrom(opts PrometheusOpts) (*PrometheusSink, error) {
|
||||
gauges: sync.Map{},
|
||||
summaries: sync.Map{},
|
||||
counters: sync.Map{},
|
||||
updates: sync.Map{},
|
||||
expiration: opts.Expiration,
|
||||
}
|
||||
|
||||
@@ -72,32 +84,35 @@ func (p *PrometheusSink) Collect(c chan<- prometheus.Metric) {
|
||||
expire := p.expiration != 0
|
||||
now := time.Now()
|
||||
p.gauges.Range(func(k, v interface{}) bool {
|
||||
last, _ := p.updates.Load(k)
|
||||
if expire && last.(time.Time).Add(p.expiration).Before(now) {
|
||||
p.updates.Delete(k)
|
||||
p.gauges.Delete(k)
|
||||
} else {
|
||||
v.(prometheus.Gauge).Collect(c)
|
||||
if v != nil {
|
||||
lastUpdate := v.(*PrometheusGauge).updatedAt
|
||||
if expire && lastUpdate.Add(p.expiration).Before(now) {
|
||||
p.gauges.Delete(k)
|
||||
} else {
|
||||
v.(*PrometheusGauge).Collect(c)
|
||||
}
|
||||
}
|
||||
return true
|
||||
})
|
||||
p.summaries.Range(func(k, v interface{}) bool {
|
||||
last, _ := p.updates.Load(k)
|
||||
if expire && last.(time.Time).Add(p.expiration).Before(now) {
|
||||
p.updates.Delete(k)
|
||||
p.summaries.Delete(k)
|
||||
} else {
|
||||
v.(prometheus.Summary).Collect(c)
|
||||
if v != nil {
|
||||
lastUpdate := v.(*PrometheusSummary).updatedAt
|
||||
if expire && lastUpdate.Add(p.expiration).Before(now) {
|
||||
p.summaries.Delete(k)
|
||||
} else {
|
||||
v.(*PrometheusSummary).Collect(c)
|
||||
}
|
||||
}
|
||||
return true
|
||||
})
|
||||
p.counters.Range(func(k, v interface{}) bool {
|
||||
last, _ := p.updates.Load(k)
|
||||
if expire && last.(time.Time).Add(p.expiration).Before(now) {
|
||||
p.updates.Delete(k)
|
||||
p.counters.Delete(k)
|
||||
} else {
|
||||
v.(prometheus.Counter).Collect(c)
|
||||
if v != nil {
|
||||
lastUpdate := v.(*PrometheusCounter).updatedAt
|
||||
if expire && lastUpdate.Add(p.expiration).Before(now) {
|
||||
p.counters.Delete(k)
|
||||
} else {
|
||||
v.(*PrometheusCounter).Collect(c)
|
||||
}
|
||||
}
|
||||
return true
|
||||
})
|
||||
@@ -131,17 +146,31 @@ func (p *PrometheusSink) SetGauge(parts []string, val float32) {
|
||||
|
||||
func (p *PrometheusSink) SetGaugeWithLabels(parts []string, val float32, labels []metrics.Label) {
|
||||
key, hash := p.flattenKey(parts, labels)
|
||||
g, ok := p.gauges.Load(hash)
|
||||
if !ok {
|
||||
g = prometheus.NewGauge(prometheus.GaugeOpts{
|
||||
pg, ok := p.gauges.Load(hash)
|
||||
|
||||
// The sync.Map underlying gauges stores pointers to our structs. If we need to make updates,
|
||||
// rather than modifying the underlying value directly, which would be racy, we make a local
|
||||
// copy by dereferencing the pointer we get back, making the appropriate changes, and then
|
||||
// storing a pointer to our local copy. The underlying Prometheus types are threadsafe,
|
||||
// so there's no issues there. It's possible for racy updates to occur to the updatedAt
|
||||
// value, but since we're always setting it to time.Now(), it doesn't really matter.
|
||||
if ok {
|
||||
localGauge := *pg.(*PrometheusGauge)
|
||||
localGauge.Set(float64(val))
|
||||
localGauge.updatedAt = time.Now()
|
||||
p.gauges.Store(hash, &localGauge)
|
||||
} else {
|
||||
g := prometheus.NewGauge(prometheus.GaugeOpts{
|
||||
Name: key,
|
||||
Help: key,
|
||||
ConstLabels: prometheusLabels(labels),
|
||||
})
|
||||
p.gauges.Store(hash, g)
|
||||
g.Set(float64(val))
|
||||
pg = &PrometheusGauge{
|
||||
g, time.Now(),
|
||||
}
|
||||
p.gauges.Store(hash, pg)
|
||||
}
|
||||
g.(prometheus.Gauge).Set(float64(val))
|
||||
p.updates.Store(hash, time.Now())
|
||||
}
|
||||
|
||||
func (p *PrometheusSink) AddSample(parts []string, val float32) {
|
||||
@@ -150,19 +179,27 @@ func (p *PrometheusSink) AddSample(parts []string, val float32) {
|
||||
|
||||
func (p *PrometheusSink) AddSampleWithLabels(parts []string, val float32, labels []metrics.Label) {
|
||||
key, hash := p.flattenKey(parts, labels)
|
||||
g, ok := p.summaries.Load(hash)
|
||||
if !ok {
|
||||
g = prometheus.NewSummary(prometheus.SummaryOpts{
|
||||
ps, ok := p.summaries.Load(hash)
|
||||
|
||||
if ok {
|
||||
localSummary := *ps.(*PrometheusSummary)
|
||||
localSummary.Observe(float64(val))
|
||||
localSummary.updatedAt = time.Now()
|
||||
p.summaries.Store(hash, &localSummary)
|
||||
} else {
|
||||
s := prometheus.NewSummary(prometheus.SummaryOpts{
|
||||
Name: key,
|
||||
Help: key,
|
||||
MaxAge: 10 * time.Second,
|
||||
ConstLabels: prometheusLabels(labels),
|
||||
Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001},
|
||||
})
|
||||
p.summaries.Store(hash, g)
|
||||
s.Observe(float64(val))
|
||||
ps = &PrometheusSummary{
|
||||
s, time.Now(),
|
||||
}
|
||||
p.summaries.Store(hash, ps)
|
||||
}
|
||||
g.(prometheus.Summary).Observe(float64(val))
|
||||
p.updates.Store(hash, time.Now())
|
||||
}
|
||||
|
||||
// EmitKey is not implemented. Prometheus doesn’t offer a type for which an
|
||||
@@ -177,17 +214,25 @@ func (p *PrometheusSink) IncrCounter(parts []string, val float32) {
|
||||
|
||||
func (p *PrometheusSink) IncrCounterWithLabels(parts []string, val float32, labels []metrics.Label) {
|
||||
key, hash := p.flattenKey(parts, labels)
|
||||
g, ok := p.counters.Load(hash)
|
||||
if !ok {
|
||||
g = prometheus.NewCounter(prometheus.CounterOpts{
|
||||
pc, ok := p.counters.Load(hash)
|
||||
|
||||
if ok {
|
||||
localCounter := *pc.(*PrometheusCounter)
|
||||
localCounter.Add(float64(val))
|
||||
localCounter.updatedAt = time.Now()
|
||||
p.counters.Store(hash, &localCounter)
|
||||
} else {
|
||||
c := prometheus.NewCounter(prometheus.CounterOpts{
|
||||
Name: key,
|
||||
Help: key,
|
||||
ConstLabels: prometheusLabels(labels),
|
||||
})
|
||||
p.counters.Store(hash, g)
|
||||
c.Add(float64(val))
|
||||
pc = &PrometheusCounter{
|
||||
c, time.Now(),
|
||||
}
|
||||
p.counters.Store(hash, pc)
|
||||
}
|
||||
g.(prometheus.Counter).Add(float64(val))
|
||||
p.updates.Store(hash, time.Now())
|
||||
}
|
||||
|
||||
type PrometheusPushSink struct {
|
||||
@@ -199,12 +244,10 @@ type PrometheusPushSink struct {
|
||||
}
|
||||
|
||||
func NewPrometheusPushSink(address string, pushIterval time.Duration, name string) (*PrometheusPushSink, error) {
|
||||
|
||||
promSink := &PrometheusSink{
|
||||
gauges: sync.Map{},
|
||||
summaries: sync.Map{},
|
||||
counters: sync.Map{},
|
||||
updates: sync.Map{},
|
||||
expiration: 60 * time.Second,
|
||||
}
|
||||
|
||||
|
||||
8
vendor/github.com/hashicorp/nomad/api/services.go
generated
vendored
8
vendor/github.com/hashicorp/nomad/api/services.go
generated
vendored
@@ -138,6 +138,14 @@ func (s *Service) Canonicalize(t *Task, tg *TaskGroup, job *Job) {
|
||||
for i, check := range s.Checks {
|
||||
s.Checks[i].CheckRestart = s.CheckRestart.Merge(check.CheckRestart)
|
||||
s.Checks[i].CheckRestart.Canonicalize()
|
||||
|
||||
if s.Checks[i].SuccessBeforePassing < 0 {
|
||||
s.Checks[i].SuccessBeforePassing = 0
|
||||
}
|
||||
|
||||
if s.Checks[i].FailuresBeforeCritical < 0 {
|
||||
s.Checks[i].FailuresBeforeCritical = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
2
vendor/github.com/hashicorp/nomad/api/tasks.go
generated
vendored
2
vendor/github.com/hashicorp/nomad/api/tasks.go
generated
vendored
@@ -925,6 +925,7 @@ type TaskEvent struct {
|
||||
Time int64
|
||||
DisplayMessage string
|
||||
Details map[string]string
|
||||
Message string
|
||||
// DEPRECATION NOTICE: The following fields are all deprecated. see TaskEvent struct in structs.go for details.
|
||||
FailsTask bool
|
||||
RestartReason string
|
||||
@@ -933,7 +934,6 @@ type TaskEvent struct {
|
||||
DriverMessage string
|
||||
ExitCode int
|
||||
Signal int
|
||||
Message string
|
||||
KillReason string
|
||||
KillTimeout time.Duration
|
||||
KillError string
|
||||
|
||||
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
@@ -60,7 +60,7 @@ github.com/apparentlymart/go-textseg/v12/textseg
|
||||
# github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e
|
||||
## explicit
|
||||
github.com/armon/circbuf
|
||||
# github.com/armon/go-metrics v0.3.3
|
||||
# github.com/armon/go-metrics v0.3.4
|
||||
## explicit
|
||||
github.com/armon/go-metrics
|
||||
github.com/armon/go-metrics/circonus
|
||||
|
||||
Reference in New Issue
Block a user