Update prometheus client and go-metrics
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
2
vendor/github.com/docker/go-metrics/README.md
generated
vendored
2
vendor/github.com/docker/go-metrics/README.md
generated
vendored
@@ -70,7 +70,7 @@ Package documentation can be found [here](https://godoc.org/github.com/docker/go
|
||||
|
||||
## Additional Metrics
|
||||
|
||||
Additional metrics are also defined here that are not avaliable in the prometheus client.
|
||||
Additional metrics are also defined here that are not available in the prometheus client.
|
||||
If you need a custom metrics and it is generic enough to be used by multiple projects, define it here.
|
||||
|
||||
|
||||
|
18
vendor/github.com/docker/go-metrics/namespace.go
generated
vendored
18
vendor/github.com/docker/go-metrics/namespace.go
generated
vendored
@@ -66,7 +66,7 @@ func (n *Namespace) newCounterOpts(name, help string) prometheus.CounterOpts {
|
||||
return prometheus.CounterOpts{
|
||||
Namespace: n.name,
|
||||
Subsystem: n.subsystem,
|
||||
Name: fmt.Sprintf("%s_%s", name, Total),
|
||||
Name: makeName(name, Total),
|
||||
Help: help,
|
||||
ConstLabels: prometheus.Labels(n.labels),
|
||||
}
|
||||
@@ -92,7 +92,7 @@ func (n *Namespace) newTimerOpts(name, help string) prometheus.HistogramOpts {
|
||||
return prometheus.HistogramOpts{
|
||||
Namespace: n.name,
|
||||
Subsystem: n.subsystem,
|
||||
Name: fmt.Sprintf("%s_%s", name, Seconds),
|
||||
Name: makeName(name, Seconds),
|
||||
Help: help,
|
||||
ConstLabels: prometheus.Labels(n.labels),
|
||||
}
|
||||
@@ -118,7 +118,7 @@ func (n *Namespace) newGaugeOpts(name, help string, unit Unit) prometheus.GaugeO
|
||||
return prometheus.GaugeOpts{
|
||||
Namespace: n.name,
|
||||
Subsystem: n.subsystem,
|
||||
Name: fmt.Sprintf("%s_%s", name, unit),
|
||||
Name: makeName(name, unit),
|
||||
Help: help,
|
||||
ConstLabels: prometheus.Labels(n.labels),
|
||||
}
|
||||
@@ -149,9 +149,7 @@ func (n *Namespace) Add(collector prometheus.Collector) {
|
||||
}
|
||||
|
||||
func (n *Namespace) NewDesc(name, help string, unit Unit, labels ...string) *prometheus.Desc {
|
||||
if string(unit) != "" {
|
||||
name = fmt.Sprintf("%s_%s", name, unit)
|
||||
}
|
||||
name = makeName(name, unit)
|
||||
namespace := n.name
|
||||
if n.subsystem != "" {
|
||||
namespace = fmt.Sprintf("%s_%s", namespace, n.subsystem)
|
||||
@@ -173,3 +171,11 @@ func mergeLabels(lbs ...Labels) Labels {
|
||||
|
||||
return merged
|
||||
}
|
||||
|
||||
func makeName(name string, unit Unit) string {
|
||||
if unit == "" {
|
||||
return name
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%s_%s", name, unit)
|
||||
}
|
||||
|
29
vendor/github.com/docker/go-metrics/timer.go
generated
vendored
29
vendor/github.com/docker/go-metrics/timer.go
generated
vendored
@@ -28,15 +28,27 @@ type Timer interface {
|
||||
|
||||
// LabeledTimer is a timer that must have label values populated before use.
|
||||
type LabeledTimer interface {
|
||||
WithValues(labels ...string) Timer
|
||||
WithValues(labels ...string) *labeledTimerObserver
|
||||
}
|
||||
|
||||
type labeledTimer struct {
|
||||
m *prometheus.HistogramVec
|
||||
}
|
||||
|
||||
func (lt *labeledTimer) WithValues(labels ...string) Timer {
|
||||
return &timer{m: lt.m.WithLabelValues(labels...)}
|
||||
type labeledTimerObserver struct {
|
||||
m prometheus.Observer
|
||||
}
|
||||
|
||||
func (lbo *labeledTimerObserver) Update(duration time.Duration) {
|
||||
lbo.m.Observe(duration.Seconds())
|
||||
}
|
||||
|
||||
func (lbo *labeledTimerObserver) UpdateSince(since time.Time) {
|
||||
lbo.m.Observe(time.Since(since).Seconds())
|
||||
}
|
||||
|
||||
func (lt *labeledTimer) WithValues(labels ...string) *labeledTimerObserver {
|
||||
return &labeledTimerObserver{m: lt.m.WithLabelValues(labels...)}
|
||||
}
|
||||
|
||||
func (lt *labeledTimer) Describe(c chan<- *prometheus.Desc) {
|
||||
@@ -48,7 +60,7 @@ func (lt *labeledTimer) Collect(c chan<- prometheus.Metric) {
|
||||
}
|
||||
|
||||
type timer struct {
|
||||
m prometheus.Histogram
|
||||
m prometheus.Observer
|
||||
}
|
||||
|
||||
func (t *timer) Update(duration time.Duration) {
|
||||
@@ -60,9 +72,14 @@ func (t *timer) UpdateSince(since time.Time) {
|
||||
}
|
||||
|
||||
func (t *timer) Describe(c chan<- *prometheus.Desc) {
|
||||
t.m.Describe(c)
|
||||
c <- t.m.(prometheus.Metric).Desc()
|
||||
}
|
||||
|
||||
func (t *timer) Collect(c chan<- prometheus.Metric) {
|
||||
t.m.Collect(c)
|
||||
// Are there any observers that don't implement Collector? It is really
|
||||
// unclear what the point of the upstream change was, but we'll let this
|
||||
// panic if we get an observer that doesn't implement collector. In this
|
||||
// case, we should almost always see metricVec objects, so this should
|
||||
// never panic.
|
||||
t.m.(prometheus.Collector).Collect(c)
|
||||
}
|
||||
|
Reference in New Issue
Block a user