mirror of
https://github.com/prometheus/node_exporter.git
synced 2025-03-05 21:00:12 -08:00
Update client_golang
This commit is contained in:
parent
ad2eb4a788
commit
17e71b0a16
12
vendor/github.com/prometheus/client_golang/prometheus/counter.go
generated
vendored
12
vendor/github.com/prometheus/client_golang/prometheus/counter.go
generated
vendored
|
@ -30,16 +30,8 @@ type Counter interface {
|
||||||
Metric
|
Metric
|
||||||
Collector
|
Collector
|
||||||
|
|
||||||
// Set is used to set the Counter to an arbitrary value. It is only used
|
// Inc increments the counter by 1. Use Add to increment it by arbitrary
|
||||||
// if you have to transfer a value from an external counter into this
|
// non-negative values.
|
||||||
// Prometheus metric. Do not use it for regular handling of a
|
|
||||||
// Prometheus counter (as it can be used to break the contract of
|
|
||||||
// monotonically increasing values).
|
|
||||||
//
|
|
||||||
// Deprecated: Use NewConstMetric to create a counter for an external
|
|
||||||
// value. A Counter should never be set.
|
|
||||||
Set(float64)
|
|
||||||
// Inc increments the counter by 1.
|
|
||||||
Inc()
|
Inc()
|
||||||
// Add adds the given value to the counter. It panics if the value is <
|
// Add adds the given value to the counter. It panics if the value is <
|
||||||
// 0.
|
// 0.
|
||||||
|
|
13
vendor/github.com/prometheus/client_golang/prometheus/desc.go
generated
vendored
13
vendor/github.com/prometheus/client_golang/prometheus/desc.go
generated
vendored
|
@ -16,20 +16,15 @@ package prometheus
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"regexp"
|
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/golang/protobuf/proto"
|
"github.com/golang/protobuf/proto"
|
||||||
|
"github.com/prometheus/common/model"
|
||||||
|
|
||||||
dto "github.com/prometheus/client_model/go"
|
dto "github.com/prometheus/client_model/go"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
|
||||||
metricNameRE = regexp.MustCompile(`^[a-zA-Z_][a-zA-Z0-9_:]*$`)
|
|
||||||
labelNameRE = regexp.MustCompile("^[a-zA-Z_][a-zA-Z0-9_]*$")
|
|
||||||
)
|
|
||||||
|
|
||||||
// reservedLabelPrefix is a prefix which is not legal in user-supplied
|
// reservedLabelPrefix is a prefix which is not legal in user-supplied
|
||||||
// label names.
|
// label names.
|
||||||
const reservedLabelPrefix = "__"
|
const reservedLabelPrefix = "__"
|
||||||
|
@ -78,7 +73,7 @@ type Desc struct {
|
||||||
// Help string. Each Desc with the same fqName must have the same
|
// Help string. Each Desc with the same fqName must have the same
|
||||||
// dimHash.
|
// dimHash.
|
||||||
dimHash uint64
|
dimHash uint64
|
||||||
// err is an error that occured during construction. It is reported on
|
// err is an error that occurred during construction. It is reported on
|
||||||
// registration time.
|
// registration time.
|
||||||
err error
|
err error
|
||||||
}
|
}
|
||||||
|
@ -103,7 +98,7 @@ func NewDesc(fqName, help string, variableLabels []string, constLabels Labels) *
|
||||||
d.err = errors.New("empty help string")
|
d.err = errors.New("empty help string")
|
||||||
return d
|
return d
|
||||||
}
|
}
|
||||||
if !metricNameRE.MatchString(fqName) {
|
if !model.IsValidMetricName(model.LabelValue(fqName)) {
|
||||||
d.err = fmt.Errorf("%q is not a valid metric name", fqName)
|
d.err = fmt.Errorf("%q is not a valid metric name", fqName)
|
||||||
return d
|
return d
|
||||||
}
|
}
|
||||||
|
@ -200,6 +195,6 @@ func (d *Desc) String() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkLabelName(l string) bool {
|
func checkLabelName(l string) bool {
|
||||||
return labelNameRE.MatchString(l) &&
|
return model.LabelName(l).IsValid() &&
|
||||||
!strings.HasPrefix(l, reservedLabelPrefix)
|
!strings.HasPrefix(l, reservedLabelPrefix)
|
||||||
}
|
}
|
||||||
|
|
2
vendor/github.com/prometheus/client_golang/prometheus/doc.go
generated
vendored
2
vendor/github.com/prometheus/client_golang/prometheus/doc.go
generated
vendored
|
@ -59,7 +59,7 @@
|
||||||
// // The Handler function provides a default handler to expose metrics
|
// // The Handler function provides a default handler to expose metrics
|
||||||
// // via an HTTP server. "/metrics" is the usual endpoint for that.
|
// // via an HTTP server. "/metrics" is the usual endpoint for that.
|
||||||
// http.Handle("/metrics", promhttp.Handler())
|
// http.Handle("/metrics", promhttp.Handler())
|
||||||
// http.ListenAndServe(":8080", nil)
|
// log.Fatal(http.ListenAndServe(":8080", nil))
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
|
13
vendor/github.com/prometheus/client_golang/prometheus/gauge.go
generated
vendored
13
vendor/github.com/prometheus/client_golang/prometheus/gauge.go
generated
vendored
|
@ -27,16 +27,21 @@ type Gauge interface {
|
||||||
|
|
||||||
// Set sets the Gauge to an arbitrary value.
|
// Set sets the Gauge to an arbitrary value.
|
||||||
Set(float64)
|
Set(float64)
|
||||||
// Inc increments the Gauge by 1.
|
// Inc increments the Gauge by 1. Use Add to increment it by arbitrary
|
||||||
|
// values.
|
||||||
Inc()
|
Inc()
|
||||||
// Dec decrements the Gauge by 1.
|
// Dec decrements the Gauge by 1. Use Sub to decrement it by arbitrary
|
||||||
|
// values.
|
||||||
Dec()
|
Dec()
|
||||||
// Add adds the given value to the Gauge. (The value can be
|
// Add adds the given value to the Gauge. (The value can be negative,
|
||||||
// negative, resulting in a decrease of the Gauge.)
|
// resulting in a decrease of the Gauge.)
|
||||||
Add(float64)
|
Add(float64)
|
||||||
// Sub subtracts the given value from the Gauge. (The value can be
|
// Sub subtracts the given value from the Gauge. (The value can be
|
||||||
// negative, resulting in an increase of the Gauge.)
|
// negative, resulting in an increase of the Gauge.)
|
||||||
Sub(float64)
|
Sub(float64)
|
||||||
|
|
||||||
|
// SetToCurrentTime sets the Gauge to the current Unix time in seconds.
|
||||||
|
SetToCurrentTime()
|
||||||
}
|
}
|
||||||
|
|
||||||
// GaugeOpts is an alias for Opts. See there for doc comments.
|
// GaugeOpts is an alias for Opts. See there for doc comments.
|
||||||
|
|
8
vendor/github.com/prometheus/client_golang/prometheus/go_collector.go
generated
vendored
8
vendor/github.com/prometheus/client_golang/prometheus/go_collector.go
generated
vendored
|
@ -48,7 +48,7 @@ func NewGoCollector() Collector {
|
||||||
}, {
|
}, {
|
||||||
desc: NewDesc(
|
desc: NewDesc(
|
||||||
memstatNamespace("sys_bytes"),
|
memstatNamespace("sys_bytes"),
|
||||||
"Number of bytes obtained by system. Sum of all system allocations.",
|
"Number of bytes obtained from system.",
|
||||||
nil, nil,
|
nil, nil,
|
||||||
),
|
),
|
||||||
eval: func(ms *runtime.MemStats) float64 { return float64(ms.Sys) },
|
eval: func(ms *runtime.MemStats) float64 { return float64(ms.Sys) },
|
||||||
|
@ -111,12 +111,12 @@ func NewGoCollector() Collector {
|
||||||
valType: GaugeValue,
|
valType: GaugeValue,
|
||||||
}, {
|
}, {
|
||||||
desc: NewDesc(
|
desc: NewDesc(
|
||||||
memstatNamespace("heap_released_bytes_total"),
|
memstatNamespace("heap_released_bytes"),
|
||||||
"Total number of heap bytes released to OS.",
|
"Number of heap bytes released to OS.",
|
||||||
nil, nil,
|
nil, nil,
|
||||||
),
|
),
|
||||||
eval: func(ms *runtime.MemStats) float64 { return float64(ms.HeapReleased) },
|
eval: func(ms *runtime.MemStats) float64 { return float64(ms.HeapReleased) },
|
||||||
valType: CounterValue,
|
valType: GaugeValue,
|
||||||
}, {
|
}, {
|
||||||
desc: NewDesc(
|
desc: NewDesc(
|
||||||
memstatNamespace("heap_objects"),
|
memstatNamespace("heap_objects"),
|
||||||
|
|
93
vendor/github.com/prometheus/client_golang/prometheus/http.go
generated
vendored
93
vendor/github.com/prometheus/client_golang/prometheus/http.go
generated
vendored
|
@ -62,7 +62,7 @@ func giveBuf(buf *bytes.Buffer) {
|
||||||
//
|
//
|
||||||
// Deprecated: Please note the issues described in the doc comment of
|
// Deprecated: Please note the issues described in the doc comment of
|
||||||
// InstrumentHandler. You might want to consider using promhttp.Handler instead
|
// InstrumentHandler. You might want to consider using promhttp.Handler instead
|
||||||
// (which is non instrumented).
|
// (which is not instrumented).
|
||||||
func Handler() http.Handler {
|
func Handler() http.Handler {
|
||||||
return InstrumentHandler("prometheus", UninstrumentedHandler())
|
return InstrumentHandler("prometheus", UninstrumentedHandler())
|
||||||
}
|
}
|
||||||
|
@ -190,6 +190,7 @@ func InstrumentHandlerFunc(handlerName string, handlerFunc func(http.ResponseWri
|
||||||
SummaryOpts{
|
SummaryOpts{
|
||||||
Subsystem: "http",
|
Subsystem: "http",
|
||||||
ConstLabels: Labels{"handler": handlerName},
|
ConstLabels: Labels{"handler": handlerName},
|
||||||
|
Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001},
|
||||||
},
|
},
|
||||||
handlerFunc,
|
handlerFunc,
|
||||||
)
|
)
|
||||||
|
@ -245,34 +246,52 @@ func InstrumentHandlerFuncWithOpts(opts SummaryOpts, handlerFunc func(http.Respo
|
||||||
},
|
},
|
||||||
instLabels,
|
instLabels,
|
||||||
)
|
)
|
||||||
|
if err := Register(reqCnt); err != nil {
|
||||||
|
if are, ok := err.(AlreadyRegisteredError); ok {
|
||||||
|
reqCnt = are.ExistingCollector.(*CounterVec)
|
||||||
|
} else {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
opts.Name = "request_duration_microseconds"
|
opts.Name = "request_duration_microseconds"
|
||||||
opts.Help = "The HTTP request latencies in microseconds."
|
opts.Help = "The HTTP request latencies in microseconds."
|
||||||
reqDur := NewSummary(opts)
|
reqDur := NewSummary(opts)
|
||||||
|
if err := Register(reqDur); err != nil {
|
||||||
|
if are, ok := err.(AlreadyRegisteredError); ok {
|
||||||
|
reqDur = are.ExistingCollector.(Summary)
|
||||||
|
} else {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
opts.Name = "request_size_bytes"
|
opts.Name = "request_size_bytes"
|
||||||
opts.Help = "The HTTP request sizes in bytes."
|
opts.Help = "The HTTP request sizes in bytes."
|
||||||
reqSz := NewSummary(opts)
|
reqSz := NewSummary(opts)
|
||||||
|
if err := Register(reqSz); err != nil {
|
||||||
|
if are, ok := err.(AlreadyRegisteredError); ok {
|
||||||
|
reqSz = are.ExistingCollector.(Summary)
|
||||||
|
} else {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
opts.Name = "response_size_bytes"
|
opts.Name = "response_size_bytes"
|
||||||
opts.Help = "The HTTP response sizes in bytes."
|
opts.Help = "The HTTP response sizes in bytes."
|
||||||
resSz := NewSummary(opts)
|
resSz := NewSummary(opts)
|
||||||
|
if err := Register(resSz); err != nil {
|
||||||
regReqCnt := MustRegisterOrGet(reqCnt).(*CounterVec)
|
if are, ok := err.(AlreadyRegisteredError); ok {
|
||||||
regReqDur := MustRegisterOrGet(reqDur).(Summary)
|
resSz = are.ExistingCollector.(Summary)
|
||||||
regReqSz := MustRegisterOrGet(reqSz).(Summary)
|
} else {
|
||||||
regResSz := MustRegisterOrGet(resSz).(Summary)
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
|
|
||||||
delegate := &responseWriterDelegator{ResponseWriter: w}
|
delegate := &responseWriterDelegator{ResponseWriter: w}
|
||||||
out := make(chan int)
|
out := computeApproximateRequestSize(r)
|
||||||
urlLen := 0
|
|
||||||
if r.URL != nil {
|
|
||||||
urlLen = len(r.URL.String())
|
|
||||||
}
|
|
||||||
go computeApproximateRequestSize(r, out, urlLen)
|
|
||||||
|
|
||||||
_, cn := w.(http.CloseNotifier)
|
_, cn := w.(http.CloseNotifier)
|
||||||
_, fl := w.(http.Flusher)
|
_, fl := w.(http.Flusher)
|
||||||
|
@ -290,30 +309,44 @@ func InstrumentHandlerFuncWithOpts(opts SummaryOpts, handlerFunc func(http.Respo
|
||||||
|
|
||||||
method := sanitizeMethod(r.Method)
|
method := sanitizeMethod(r.Method)
|
||||||
code := sanitizeCode(delegate.status)
|
code := sanitizeCode(delegate.status)
|
||||||
regReqCnt.WithLabelValues(method, code).Inc()
|
reqCnt.WithLabelValues(method, code).Inc()
|
||||||
regReqDur.Observe(elapsed)
|
reqDur.Observe(elapsed)
|
||||||
regResSz.Observe(float64(delegate.written))
|
resSz.Observe(float64(delegate.written))
|
||||||
regReqSz.Observe(float64(<-out))
|
reqSz.Observe(float64(<-out))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func computeApproximateRequestSize(r *http.Request, out chan int, s int) {
|
func computeApproximateRequestSize(r *http.Request) <-chan int {
|
||||||
s += len(r.Method)
|
// Get URL length in current go routine for avoiding a race condition.
|
||||||
s += len(r.Proto)
|
// HandlerFunc that runs in parallel may modify the URL.
|
||||||
for name, values := range r.Header {
|
s := 0
|
||||||
s += len(name)
|
if r.URL != nil {
|
||||||
for _, value := range values {
|
s += len(r.URL.String())
|
||||||
s += len(value)
|
}
|
||||||
|
|
||||||
|
out := make(chan int, 1)
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
s += len(r.Method)
|
||||||
|
s += len(r.Proto)
|
||||||
|
for name, values := range r.Header {
|
||||||
|
s += len(name)
|
||||||
|
for _, value := range values {
|
||||||
|
s += len(value)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
s += len(r.Host)
|
||||||
s += len(r.Host)
|
|
||||||
|
|
||||||
// N.B. r.Form and r.MultipartForm are assumed to be included in r.URL.
|
// N.B. r.Form and r.MultipartForm are assumed to be included in r.URL.
|
||||||
|
|
||||||
if r.ContentLength != -1 {
|
if r.ContentLength != -1 {
|
||||||
s += int(r.ContentLength)
|
s += int(r.ContentLength)
|
||||||
}
|
}
|
||||||
out <- s
|
out <- s
|
||||||
|
close(out)
|
||||||
|
}()
|
||||||
|
|
||||||
|
return out
|
||||||
}
|
}
|
||||||
|
|
||||||
type responseWriterDelegator struct {
|
type responseWriterDelegator struct {
|
||||||
|
|
104
vendor/github.com/prometheus/client_golang/prometheus/process_collector.go
generated
vendored
104
vendor/github.com/prometheus/client_golang/prometheus/process_collector.go
generated
vendored
|
@ -19,10 +19,10 @@ type processCollector struct {
|
||||||
pid int
|
pid int
|
||||||
collectFn func(chan<- Metric)
|
collectFn func(chan<- Metric)
|
||||||
pidFn func() (int, error)
|
pidFn func() (int, error)
|
||||||
cpuTotal Counter
|
cpuTotal *Desc
|
||||||
openFDs, maxFDs Gauge
|
openFDs, maxFDs *Desc
|
||||||
vsize, rss Gauge
|
vsize, rss *Desc
|
||||||
startTime Gauge
|
startTime *Desc
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewProcessCollector returns a collector which exports the current state of
|
// NewProcessCollector returns a collector which exports the current state of
|
||||||
|
@ -44,40 +44,45 @@ func NewProcessCollectorPIDFn(
|
||||||
pidFn func() (int, error),
|
pidFn func() (int, error),
|
||||||
namespace string,
|
namespace string,
|
||||||
) Collector {
|
) Collector {
|
||||||
|
ns := ""
|
||||||
|
if len(namespace) > 0 {
|
||||||
|
ns = namespace + "_"
|
||||||
|
}
|
||||||
|
|
||||||
c := processCollector{
|
c := processCollector{
|
||||||
pidFn: pidFn,
|
pidFn: pidFn,
|
||||||
collectFn: func(chan<- Metric) {},
|
collectFn: func(chan<- Metric) {},
|
||||||
|
|
||||||
cpuTotal: NewCounter(CounterOpts{
|
cpuTotal: NewDesc(
|
||||||
Namespace: namespace,
|
ns+"process_cpu_seconds_total",
|
||||||
Name: "process_cpu_seconds_total",
|
"Total user and system CPU time spent in seconds.",
|
||||||
Help: "Total user and system CPU time spent in seconds.",
|
nil, nil,
|
||||||
}),
|
),
|
||||||
openFDs: NewGauge(GaugeOpts{
|
openFDs: NewDesc(
|
||||||
Namespace: namespace,
|
ns+"process_open_fds",
|
||||||
Name: "process_open_fds",
|
"Number of open file descriptors.",
|
||||||
Help: "Number of open file descriptors.",
|
nil, nil,
|
||||||
}),
|
),
|
||||||
maxFDs: NewGauge(GaugeOpts{
|
maxFDs: NewDesc(
|
||||||
Namespace: namespace,
|
ns+"process_max_fds",
|
||||||
Name: "process_max_fds",
|
"Maximum number of open file descriptors.",
|
||||||
Help: "Maximum number of open file descriptors.",
|
nil, nil,
|
||||||
}),
|
),
|
||||||
vsize: NewGauge(GaugeOpts{
|
vsize: NewDesc(
|
||||||
Namespace: namespace,
|
ns+"process_virtual_memory_bytes",
|
||||||
Name: "process_virtual_memory_bytes",
|
"Virtual memory size in bytes.",
|
||||||
Help: "Virtual memory size in bytes.",
|
nil, nil,
|
||||||
}),
|
),
|
||||||
rss: NewGauge(GaugeOpts{
|
rss: NewDesc(
|
||||||
Namespace: namespace,
|
ns+"process_resident_memory_bytes",
|
||||||
Name: "process_resident_memory_bytes",
|
"Resident memory size in bytes.",
|
||||||
Help: "Resident memory size in bytes.",
|
nil, nil,
|
||||||
}),
|
),
|
||||||
startTime: NewGauge(GaugeOpts{
|
startTime: NewDesc(
|
||||||
Namespace: namespace,
|
ns+"process_start_time_seconds",
|
||||||
Name: "process_start_time_seconds",
|
"Start time of the process since unix epoch in seconds.",
|
||||||
Help: "Start time of the process since unix epoch in seconds.",
|
nil, nil,
|
||||||
}),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set up process metric collection if supported by the runtime.
|
// Set up process metric collection if supported by the runtime.
|
||||||
|
@ -90,12 +95,12 @@ func NewProcessCollectorPIDFn(
|
||||||
|
|
||||||
// Describe returns all descriptions of the collector.
|
// Describe returns all descriptions of the collector.
|
||||||
func (c *processCollector) Describe(ch chan<- *Desc) {
|
func (c *processCollector) Describe(ch chan<- *Desc) {
|
||||||
ch <- c.cpuTotal.Desc()
|
ch <- c.cpuTotal
|
||||||
ch <- c.openFDs.Desc()
|
ch <- c.openFDs
|
||||||
ch <- c.maxFDs.Desc()
|
ch <- c.maxFDs
|
||||||
ch <- c.vsize.Desc()
|
ch <- c.vsize
|
||||||
ch <- c.rss.Desc()
|
ch <- c.rss
|
||||||
ch <- c.startTime.Desc()
|
ch <- c.startTime
|
||||||
}
|
}
|
||||||
|
|
||||||
// Collect returns the current state of all metrics of the collector.
|
// Collect returns the current state of all metrics of the collector.
|
||||||
|
@ -117,26 +122,19 @@ func (c *processCollector) processCollect(ch chan<- Metric) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if stat, err := p.NewStat(); err == nil {
|
if stat, err := p.NewStat(); err == nil {
|
||||||
c.cpuTotal.Set(stat.CPUTime())
|
ch <- MustNewConstMetric(c.cpuTotal, CounterValue, stat.CPUTime())
|
||||||
ch <- c.cpuTotal
|
ch <- MustNewConstMetric(c.vsize, GaugeValue, float64(stat.VirtualMemory()))
|
||||||
c.vsize.Set(float64(stat.VirtualMemory()))
|
ch <- MustNewConstMetric(c.rss, GaugeValue, float64(stat.ResidentMemory()))
|
||||||
ch <- c.vsize
|
|
||||||
c.rss.Set(float64(stat.ResidentMemory()))
|
|
||||||
ch <- c.rss
|
|
||||||
|
|
||||||
if startTime, err := stat.StartTime(); err == nil {
|
if startTime, err := stat.StartTime(); err == nil {
|
||||||
c.startTime.Set(startTime)
|
ch <- MustNewConstMetric(c.startTime, GaugeValue, startTime)
|
||||||
ch <- c.startTime
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if fds, err := p.FileDescriptorsLen(); err == nil {
|
if fds, err := p.FileDescriptorsLen(); err == nil {
|
||||||
c.openFDs.Set(float64(fds))
|
ch <- MustNewConstMetric(c.openFDs, GaugeValue, float64(fds))
|
||||||
ch <- c.openFDs
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if limits, err := p.NewLimits(); err == nil {
|
if limits, err := p.NewLimits(); err == nil {
|
||||||
c.maxFDs.Set(float64(limits.OpenFiles))
|
ch <- MustNewConstMetric(c.maxFDs, GaugeValue, float64(limits.OpenFiles))
|
||||||
ch <- c.maxFDs
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
55
vendor/github.com/prometheus/client_golang/prometheus/registry.go
generated
vendored
55
vendor/github.com/prometheus/client_golang/prometheus/registry.go
generated
vendored
|
@ -152,38 +152,6 @@ func MustRegister(cs ...Collector) {
|
||||||
DefaultRegisterer.MustRegister(cs...)
|
DefaultRegisterer.MustRegister(cs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// RegisterOrGet registers the provided Collector with the DefaultRegisterer and
|
|
||||||
// returns the Collector, unless an equal Collector was registered before, in
|
|
||||||
// which case that Collector is returned.
|
|
||||||
//
|
|
||||||
// Deprecated: RegisterOrGet is merely a convenience function for the
|
|
||||||
// implementation as described in the documentation for
|
|
||||||
// AlreadyRegisteredError. As the use case is relatively rare, this function
|
|
||||||
// will be removed in a future version of this package to clean up the
|
|
||||||
// namespace.
|
|
||||||
func RegisterOrGet(c Collector) (Collector, error) {
|
|
||||||
if err := Register(c); err != nil {
|
|
||||||
if are, ok := err.(AlreadyRegisteredError); ok {
|
|
||||||
return are.ExistingCollector, nil
|
|
||||||
}
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return c, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// MustRegisterOrGet behaves like RegisterOrGet but panics instead of returning
|
|
||||||
// an error.
|
|
||||||
//
|
|
||||||
// Deprecated: This is deprecated for the same reason RegisterOrGet is. See
|
|
||||||
// there for details.
|
|
||||||
func MustRegisterOrGet(c Collector) Collector {
|
|
||||||
c, err := RegisterOrGet(c)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return c
|
|
||||||
}
|
|
||||||
|
|
||||||
// Unregister removes the registration of the provided Collector from the
|
// Unregister removes the registration of the provided Collector from the
|
||||||
// DefaultRegisterer.
|
// DefaultRegisterer.
|
||||||
//
|
//
|
||||||
|
@ -201,25 +169,6 @@ func (gf GathererFunc) Gather() ([]*dto.MetricFamily, error) {
|
||||||
return gf()
|
return gf()
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetMetricFamilyInjectionHook replaces the DefaultGatherer with one that
|
|
||||||
// gathers from the previous DefaultGatherers but then merges the MetricFamily
|
|
||||||
// protobufs returned from the provided hook function with the MetricFamily
|
|
||||||
// protobufs returned from the original DefaultGatherer.
|
|
||||||
//
|
|
||||||
// Deprecated: This function manipulates the DefaultGatherer variable. Consider
|
|
||||||
// the implications, i.e. don't do this concurrently with any uses of the
|
|
||||||
// DefaultGatherer. In the rare cases where you need to inject MetricFamily
|
|
||||||
// protobufs directly, it is recommended to use a custom Registry and combine it
|
|
||||||
// with a custom Gatherer using the Gatherers type (see
|
|
||||||
// there). SetMetricFamilyInjectionHook only exists for compatibility reasons
|
|
||||||
// with previous versions of this package.
|
|
||||||
func SetMetricFamilyInjectionHook(hook func() []*dto.MetricFamily) {
|
|
||||||
DefaultGatherer = Gatherers{
|
|
||||||
DefaultGatherer,
|
|
||||||
GathererFunc(func() ([]*dto.MetricFamily, error) { return hook(), nil }),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// AlreadyRegisteredError is returned by the Register method if the Collector to
|
// AlreadyRegisteredError is returned by the Register method if the Collector to
|
||||||
// be registered has already been registered before, or a different Collector
|
// be registered has already been registered before, or a different Collector
|
||||||
// that collects the same metrics has been registered before. Registration fails
|
// that collects the same metrics has been registered before. Registration fails
|
||||||
|
@ -447,7 +396,7 @@ func (r *Registry) Gather() ([]*dto.MetricFamily, error) {
|
||||||
|
|
||||||
// Drain metricChan in case of premature return.
|
// Drain metricChan in case of premature return.
|
||||||
defer func() {
|
defer func() {
|
||||||
for _ = range metricChan {
|
for range metricChan {
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
@ -683,7 +632,7 @@ func (s metricSorter) Less(i, j int) bool {
|
||||||
return s[i].GetTimestampMs() < s[j].GetTimestampMs()
|
return s[i].GetTimestampMs() < s[j].GetTimestampMs()
|
||||||
}
|
}
|
||||||
|
|
||||||
// normalizeMetricFamilies returns a MetricFamily slice whith empty
|
// normalizeMetricFamilies returns a MetricFamily slice with empty
|
||||||
// MetricFamilies pruned and the remaining MetricFamilies sorted by name within
|
// MetricFamilies pruned and the remaining MetricFamilies sorted by name within
|
||||||
// the slice, with the contained Metrics sorted within each MetricFamily.
|
// the slice, with the contained Metrics sorted within each MetricFamily.
|
||||||
func normalizeMetricFamilies(metricFamiliesByName map[string]*dto.MetricFamily) []*dto.MetricFamily {
|
func normalizeMetricFamilies(metricFamiliesByName map[string]*dto.MetricFamily) []*dto.MetricFamily {
|
||||||
|
|
17
vendor/github.com/prometheus/client_golang/prometheus/summary.go
generated
vendored
17
vendor/github.com/prometheus/client_golang/prometheus/summary.go
generated
vendored
|
@ -54,6 +54,9 @@ type Summary interface {
|
||||||
}
|
}
|
||||||
|
|
||||||
// DefObjectives are the default Summary quantile values.
|
// DefObjectives are the default Summary quantile values.
|
||||||
|
//
|
||||||
|
// Deprecated: DefObjectives will not be used as the default objectives in
|
||||||
|
// v0.10 of the library. The default Summary will have no quantiles then.
|
||||||
var (
|
var (
|
||||||
DefObjectives = map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001}
|
DefObjectives = map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001}
|
||||||
|
|
||||||
|
@ -113,9 +116,15 @@ type SummaryOpts struct {
|
||||||
ConstLabels Labels
|
ConstLabels Labels
|
||||||
|
|
||||||
// Objectives defines the quantile rank estimates with their respective
|
// Objectives defines the quantile rank estimates with their respective
|
||||||
// absolute error. If Objectives[q] = e, then the value reported
|
// absolute error. If Objectives[q] = e, then the value reported for q
|
||||||
// for q will be the φ-quantile value for some φ between q-e and q+e.
|
// will be the φ-quantile value for some φ between q-e and q+e. The
|
||||||
// The default value is DefObjectives.
|
// default value is DefObjectives. It is used if Objectives is left at
|
||||||
|
// its zero value (i.e. nil). To create a Summary without Objectives,
|
||||||
|
// set it to an empty map (i.e. map[float64]float64{}).
|
||||||
|
//
|
||||||
|
// Deprecated: Note that the current value of DefObjectives is
|
||||||
|
// deprecated. It will be replaced by an empty map in v0.10 of the
|
||||||
|
// library. Please explicitly set Objectives to the desired value.
|
||||||
Objectives map[float64]float64
|
Objectives map[float64]float64
|
||||||
|
|
||||||
// MaxAge defines the duration for which an observation stays relevant
|
// MaxAge defines the duration for which an observation stays relevant
|
||||||
|
@ -183,7 +192,7 @@ func newSummary(desc *Desc, opts SummaryOpts, labelValues ...string) Summary {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(opts.Objectives) == 0 {
|
if opts.Objectives == nil {
|
||||||
opts.Objectives = DefObjectives
|
opts.Objectives = DefObjectives
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
5
vendor/github.com/prometheus/client_golang/prometheus/untyped.go
generated
vendored
5
vendor/github.com/prometheus/client_golang/prometheus/untyped.go
generated
vendored
|
@ -20,6 +20,11 @@ package prometheus
|
||||||
// no type information is implied.
|
// no type information is implied.
|
||||||
//
|
//
|
||||||
// To create Untyped instances, use NewUntyped.
|
// To create Untyped instances, use NewUntyped.
|
||||||
|
//
|
||||||
|
// Deprecated: The Untyped type is deprecated because it doesn't make sense in
|
||||||
|
// direct instrumentation. If you need to mirror an external metric of unknown
|
||||||
|
// type (usually while writing exporters), Use MustNewConstMetric to create an
|
||||||
|
// untyped metric instance on the fly.
|
||||||
type Untyped interface {
|
type Untyped interface {
|
||||||
Metric
|
Metric
|
||||||
Collector
|
Collector
|
||||||
|
|
5
vendor/github.com/prometheus/client_golang/prometheus/value.go
generated
vendored
5
vendor/github.com/prometheus/client_golang/prometheus/value.go
generated
vendored
|
@ -19,6 +19,7 @@ import (
|
||||||
"math"
|
"math"
|
||||||
"sort"
|
"sort"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
"time"
|
||||||
|
|
||||||
dto "github.com/prometheus/client_model/go"
|
dto "github.com/prometheus/client_model/go"
|
||||||
|
|
||||||
|
@ -80,6 +81,10 @@ func (v *value) Set(val float64) {
|
||||||
atomic.StoreUint64(&v.valBits, math.Float64bits(val))
|
atomic.StoreUint64(&v.valBits, math.Float64bits(val))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (v *value) SetToCurrentTime() {
|
||||||
|
v.Set(float64(time.Now().UnixNano()) / 1e9)
|
||||||
|
}
|
||||||
|
|
||||||
func (v *value) Inc() {
|
func (v *value) Inc() {
|
||||||
v.Add(1)
|
v.Add(1)
|
||||||
}
|
}
|
||||||
|
|
8
vendor/vendor.json
vendored
8
vendor/vendor.json
vendored
|
@ -51,13 +51,15 @@
|
||||||
"revisionTime": "2016-04-24T11:30:07Z"
|
"revisionTime": "2016-04-24T11:30:07Z"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"checksumSHA1": "KkB+77Ziom7N6RzSbyUwYGrmDeU=",
|
"checksumSHA1": "/j0HRFJPThv7HEkZZ/gurf+5fQI=",
|
||||||
|
"origin": "github.com/prometheus/node_exporter/vendor/github.com/prometheus/client_golang/prometheus",
|
||||||
"path": "github.com/prometheus/client_golang/prometheus",
|
"path": "github.com/prometheus/client_golang/prometheus",
|
||||||
"revision": "c5b7fccd204277076155f10851dad72b76a49317",
|
"revision": "575f371f7862609249a1be4c9145f429fe065e32",
|
||||||
"revisionTime": "2016-08-17T15:48:24Z"
|
"revisionTime": "2016-11-24T15:57:32Z"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"checksumSHA1": "lG3//eDlwqA4IOuAPrNtLh9G0TA=",
|
"checksumSHA1": "lG3//eDlwqA4IOuAPrNtLh9G0TA=",
|
||||||
|
"origin": "github.com/prometheus/node_exporter/vendor/github.com/prometheus/client_golang/prometheus/promhttp",
|
||||||
"path": "github.com/prometheus/client_golang/prometheus/promhttp",
|
"path": "github.com/prometheus/client_golang/prometheus/promhttp",
|
||||||
"revision": "575f371f7862609249a1be4c9145f429fe065e32",
|
"revision": "575f371f7862609249a1be4c9145f429fe065e32",
|
||||||
"revisionTime": "2016-11-24T15:57:32Z"
|
"revisionTime": "2016-11-24T15:57:32Z"
|
||||||
|
|
Loading…
Reference in a new issue