Update vendoring. (#1257)
* Update vendoring. Update vendoring to latest upstream. Signed-off-by: Ben Kochie <superq@gmail.com>
This commit is contained in:
parent
cb9e23c536
commit
dc4c58671d
257 changed files with 39320 additions and 7619 deletions
4
vendor/github.com/prometheus/client_golang/prometheus/desc.go
generated
vendored
4
vendor/github.com/prometheus/client_golang/prometheus/desc.go
generated
vendored
|
|
@ -93,7 +93,7 @@ func NewDesc(fqName, help string, variableLabels []string, constLabels Labels) *
|
|||
// First add only the const label names and sort them...
|
||||
for labelName := range constLabels {
|
||||
if !checkLabelName(labelName) {
|
||||
d.err = fmt.Errorf("%q is not a valid label name", labelName)
|
||||
d.err = fmt.Errorf("%q is not a valid label name for metric %q", labelName, fqName)
|
||||
return d
|
||||
}
|
||||
labelNames = append(labelNames, labelName)
|
||||
|
|
@ -115,7 +115,7 @@ func NewDesc(fqName, help string, variableLabels []string, constLabels Labels) *
|
|||
// dimension with a different mix between preset and variable labels.
|
||||
for _, labelName := range variableLabels {
|
||||
if !checkLabelName(labelName) {
|
||||
d.err = fmt.Errorf("%q is not a valid label name", labelName)
|
||||
d.err = fmt.Errorf("%q is not a valid label name for metric %q", labelName, fqName)
|
||||
return d
|
||||
}
|
||||
labelNames = append(labelNames, "$"+labelName)
|
||||
|
|
|
|||
12
vendor/github.com/prometheus/client_golang/prometheus/registry.go
generated
vendored
12
vendor/github.com/prometheus/client_golang/prometheus/registry.go
generated
vendored
|
|
@ -872,7 +872,13 @@ func checkMetricConsistency(
|
|||
h = hashAddByte(h, separatorByte)
|
||||
// Make sure label pairs are sorted. We depend on it for the consistency
|
||||
// check.
|
||||
sort.Sort(labelPairSorter(dtoMetric.Label))
|
||||
if !sort.IsSorted(labelPairSorter(dtoMetric.Label)) {
|
||||
// We cannot sort dtoMetric.Label in place as it is immutable by contract.
|
||||
copiedLabels := make([]*dto.LabelPair, len(dtoMetric.Label))
|
||||
copy(copiedLabels, dtoMetric.Label)
|
||||
sort.Sort(labelPairSorter(copiedLabels))
|
||||
dtoMetric.Label = copiedLabels
|
||||
}
|
||||
for _, lp := range dtoMetric.Label {
|
||||
h = hashAdd(h, lp.GetName())
|
||||
h = hashAddByte(h, separatorByte)
|
||||
|
|
@ -903,8 +909,8 @@ func checkDescConsistency(
|
|||
}
|
||||
|
||||
// Is the desc consistent with the content of the metric?
|
||||
lpsFromDesc := make([]*dto.LabelPair, 0, len(dtoMetric.Label))
|
||||
lpsFromDesc = append(lpsFromDesc, desc.constLabelPairs...)
|
||||
lpsFromDesc := make([]*dto.LabelPair, len(desc.constLabelPairs), len(dtoMetric.Label))
|
||||
copy(lpsFromDesc, desc.constLabelPairs)
|
||||
for _, l := range desc.variableLabels {
|
||||
lpsFromDesc = append(lpsFromDesc, &dto.LabelPair{
|
||||
Name: proto.String(l),
|
||||
|
|
|
|||
11
vendor/github.com/prometheus/client_golang/prometheus/timer.go
generated
vendored
11
vendor/github.com/prometheus/client_golang/prometheus/timer.go
generated
vendored
|
|
@ -39,13 +39,16 @@ func NewTimer(o Observer) *Timer {
|
|||
|
||||
// ObserveDuration records the duration passed since the Timer was created with
|
||||
// NewTimer. It calls the Observe method of the Observer provided during
|
||||
// construction with the duration in seconds as an argument. ObserveDuration is
|
||||
// usually called with a defer statement.
|
||||
// construction with the duration in seconds as an argument. The observed
|
||||
// duration is also returned. ObserveDuration is usually called with a defer
|
||||
// statement.
|
||||
//
|
||||
// Note that this method is only guaranteed to never observe negative durations
|
||||
// if used with Go1.9+.
|
||||
func (t *Timer) ObserveDuration() {
|
||||
func (t *Timer) ObserveDuration() time.Duration {
|
||||
d := time.Since(t.begin)
|
||||
if t.observer != nil {
|
||||
t.observer.Observe(time.Since(t.begin).Seconds())
|
||||
t.observer.Observe(d.Seconds())
|
||||
}
|
||||
return d
|
||||
}
|
||||
|
|
|
|||
36
vendor/github.com/prometheus/common/expfmt/text_create.go
generated
vendored
36
vendor/github.com/prometheus/common/expfmt/text_create.go
generated
vendored
|
|
@ -19,6 +19,7 @@ import (
|
|||
"io"
|
||||
"math"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/prometheus/common/model"
|
||||
|
|
@ -43,7 +44,7 @@ const (
|
|||
var (
|
||||
bufPool = sync.Pool{
|
||||
New: func() interface{} {
|
||||
return bytes.NewBuffer(make([]byte, 0, initialNumBufSize))
|
||||
return bytes.NewBuffer(make([]byte, 0, initialBufSize))
|
||||
},
|
||||
}
|
||||
numBufPool = sync.Pool{
|
||||
|
|
@ -416,32 +417,17 @@ func writeLabelPairs(
|
|||
|
||||
// writeEscapedString replaces '\' by '\\', new line character by '\n', and - if
|
||||
// includeDoubleQuote is true - '"' by '\"'.
|
||||
var (
|
||||
escaper = strings.NewReplacer("\\", `\\`, "\n", `\n`)
|
||||
quotedEscaper = strings.NewReplacer("\\", `\\`, "\n", `\n`, "\"", `\"`)
|
||||
)
|
||||
|
||||
func writeEscapedString(w enhancedWriter, v string, includeDoubleQuote bool) (int, error) {
|
||||
var (
|
||||
written, n int
|
||||
err error
|
||||
)
|
||||
for _, r := range v {
|
||||
switch r {
|
||||
case '\\':
|
||||
n, err = w.WriteString(`\\`)
|
||||
case '\n':
|
||||
n, err = w.WriteString(`\n`)
|
||||
case '"':
|
||||
if includeDoubleQuote {
|
||||
n, err = w.WriteString(`\"`)
|
||||
} else {
|
||||
n, err = w.WriteRune(r)
|
||||
}
|
||||
default:
|
||||
n, err = w.WriteRune(r)
|
||||
}
|
||||
written += n
|
||||
if err != nil {
|
||||
return written, err
|
||||
}
|
||||
if includeDoubleQuote {
|
||||
return quotedEscaper.WriteString(w, v)
|
||||
} else {
|
||||
return escaper.WriteString(w, v)
|
||||
}
|
||||
return written, nil
|
||||
}
|
||||
|
||||
// writeFloat is equivalent to fmt.Fprint with a float64 argument but hardcodes
|
||||
|
|
|
|||
6
vendor/github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg/autoneg.go
generated
vendored
6
vendor/github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg/autoneg.go
generated
vendored
|
|
@ -1,12 +1,12 @@
|
|||
/*
|
||||
Copyright (c) 2011, Open Knowledge Foundation Ltd.
|
||||
All rights reserved.
|
||||
|
||||
HTTP Content-Type Autonegotiation.
|
||||
|
||||
The functions in this package implement the behaviour specified in
|
||||
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
|
||||
|
||||
Copyright (c) 2011, Open Knowledge Foundation Ltd.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
|
|
|||
1
vendor/github.com/prometheus/common/model/metric.go
generated
vendored
1
vendor/github.com/prometheus/common/model/metric.go
generated
vendored
|
|
@ -21,7 +21,6 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
separator = []byte{0}
|
||||
// MetricNameRE is a regular expression matching valid metric
|
||||
// names. Note that the IsValidMetricName function performs the same
|
||||
// check but faster than a match with this regular expression.
|
||||
|
|
|
|||
2
vendor/github.com/prometheus/common/model/time.go
generated
vendored
2
vendor/github.com/prometheus/common/model/time.go
generated
vendored
|
|
@ -43,7 +43,7 @@ const (
|
|||
// (1970-01-01 00:00 UTC) excluding leap seconds.
|
||||
type Time int64
|
||||
|
||||
// Interval describes and interval between two timestamps.
|
||||
// Interval describes an interval between two timestamps.
|
||||
type Interval struct {
|
||||
Start, End Time
|
||||
}
|
||||
|
|
|
|||
22
vendor/github.com/prometheus/procfs/fixtures.ttar
generated
vendored
22
vendor/github.com/prometheus/procfs/fixtures.ttar
generated
vendored
|
|
@ -404,6 +404,26 @@ XfrmOutStateInvalid 28765
|
|||
XfrmAcquireError 24532
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Directory: fixtures/pressure
|
||||
Mode: 755
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/pressure/cpu
|
||||
Lines: 1
|
||||
some avg10=0.10 avg60=2.00 avg300=3.85 total=15
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/pressure/io
|
||||
Lines: 2
|
||||
some avg10=0.10 avg60=2.00 avg300=3.85 total=15
|
||||
full avg10=0.20 avg60=3.00 avg300=4.95 total=25
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/pressure/memory
|
||||
Lines: 2
|
||||
some avg10=0.10 avg60=2.00 avg300=3.85 total=15
|
||||
full avg10=0.20 avg60=3.00 avg300=4.95 total=25
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/self
|
||||
SymlinkTo: 26231
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
@ -458,5 +478,5 @@ Mode: 644
|
|||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Path: fixtures/.unpacked
|
||||
Lines: 0
|
||||
Mode: 664
|
||||
Mode: 644
|
||||
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
|
|||
2
vendor/github.com/prometheus/procfs/go.mod
generated
vendored
2
vendor/github.com/prometheus/procfs/go.mod
generated
vendored
|
|
@ -1 +1,3 @@
|
|||
module github.com/prometheus/procfs
|
||||
|
||||
require golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4
|
||||
|
|
|
|||
2
vendor/github.com/prometheus/procfs/go.sum
generated
vendored
Normal file
2
vendor/github.com/prometheus/procfs/go.sum
generated
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 h1:YUO/7uOKsKeq9UokNS62b8FYywz3ker1l1vDZRCRefw=
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
110
vendor/github.com/prometheus/procfs/proc_psi.go
generated
vendored
Normal file
110
vendor/github.com/prometheus/procfs/proc_psi.go
generated
vendored
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
// Copyright 2019 The Prometheus Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package procfs
|
||||
|
||||
// The PSI / pressure interface is described at
|
||||
// https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/accounting/psi.txt
|
||||
// Each resource (cpu, io, memory, ...) is exposed as a single file.
|
||||
// Each file may contain up to two lines, one for "some" pressure and one for "full" pressure.
|
||||
// Each line contains several averages (over n seconds) and a total in µs.
|
||||
//
|
||||
// Example io pressure file:
|
||||
// > some avg10=0.06 avg60=0.21 avg300=0.99 total=8537362
|
||||
// > full avg10=0.00 avg60=0.13 avg300=0.96 total=8183134
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const lineFormat = "avg10=%f avg60=%f avg300=%f total=%d"
|
||||
|
||||
// PSILine is a single line of values as returned by /proc/pressure/*
|
||||
// The Avg entries are averages over n seconds, as a percentage
|
||||
// The Total line is in microseconds
|
||||
type PSILine struct {
|
||||
Avg10 float64
|
||||
Avg60 float64
|
||||
Avg300 float64
|
||||
Total uint64
|
||||
}
|
||||
|
||||
// PSIStats represent pressure stall information from /proc/pressure/*
|
||||
// Some indicates the share of time in which at least some tasks are stalled
|
||||
// Full indicates the share of time in which all non-idle tasks are stalled simultaneously
|
||||
type PSIStats struct {
|
||||
Some *PSILine
|
||||
Full *PSILine
|
||||
}
|
||||
|
||||
// NewPSIStatsForResource reads pressure stall information for the specified
|
||||
// resource. At time of writing this can be either "cpu", "memory" or "io".
|
||||
func NewPSIStatsForResource(resource string) (PSIStats, error) {
|
||||
fs, err := NewFS(DefaultMountPoint)
|
||||
if err != nil {
|
||||
return PSIStats{}, err
|
||||
}
|
||||
|
||||
return fs.NewPSIStatsForResource(resource)
|
||||
}
|
||||
|
||||
// NewPSIStatsForResource reads pressure stall information from /proc/pressure/<resource>
|
||||
func (fs FS) NewPSIStatsForResource(resource string) (PSIStats, error) {
|
||||
file, err := os.Open(fs.Path(fmt.Sprintf("%s/%s", "pressure", resource)))
|
||||
if err != nil {
|
||||
return PSIStats{}, fmt.Errorf("psi_stats: unavailable for %s", resource)
|
||||
}
|
||||
|
||||
defer file.Close()
|
||||
return parsePSIStats(resource, file)
|
||||
}
|
||||
|
||||
// parsePSIStats parses the specified file for pressure stall information
|
||||
func parsePSIStats(resource string, file io.Reader) (PSIStats, error) {
|
||||
psiStats := PSIStats{}
|
||||
stats, err := ioutil.ReadAll(file)
|
||||
if err != nil {
|
||||
return psiStats, fmt.Errorf("psi_stats: unable to read data for %s", resource)
|
||||
}
|
||||
|
||||
for _, l := range strings.Split(string(stats), "\n") {
|
||||
prefix := strings.Split(l, " ")[0]
|
||||
switch prefix {
|
||||
case "some":
|
||||
psi := PSILine{}
|
||||
_, err := fmt.Sscanf(l, fmt.Sprintf("some %s", lineFormat), &psi.Avg10, &psi.Avg60, &psi.Avg300, &psi.Total)
|
||||
if err != nil {
|
||||
return PSIStats{}, err
|
||||
}
|
||||
psiStats.Some = &psi
|
||||
case "full":
|
||||
psi := PSILine{}
|
||||
_, err := fmt.Sscanf(l, fmt.Sprintf("full %s", lineFormat), &psi.Avg10, &psi.Avg60, &psi.Avg300, &psi.Total)
|
||||
if err != nil {
|
||||
return PSIStats{}, err
|
||||
}
|
||||
psiStats.Full = &psi
|
||||
default:
|
||||
// If we encounter a line with an unknown prefix, ignore it and move on
|
||||
// Should new measurement types be added in the future we'll simply ignore them instead
|
||||
// of erroring on retrieval
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
return psiStats, nil
|
||||
}
|
||||
41
vendor/github.com/prometheus/procfs/sysfs/system_cpu.go
generated
vendored
41
vendor/github.com/prometheus/procfs/sysfs/system_cpu.go
generated
vendored
|
|
@ -20,6 +20,8 @@ import (
|
|||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/sync/errgroup"
|
||||
|
||||
"github.com/prometheus/procfs/internal/util"
|
||||
)
|
||||
|
||||
|
|
@ -35,7 +37,7 @@ type SystemCPUCpufreqStats struct {
|
|||
ScalingMaximumFrequency *uint64
|
||||
AvailableGovernors string
|
||||
Driver string
|
||||
Govenor string
|
||||
Governor string
|
||||
RelatedCpus string
|
||||
SetSpeed string
|
||||
}
|
||||
|
|
@ -56,32 +58,41 @@ func NewSystemCpufreq() ([]SystemCPUCpufreqStats, error) {
|
|||
|
||||
// NewSystemCpufreq returns CPU frequency metrics for all CPUs.
|
||||
func (fs FS) NewSystemCpufreq() ([]SystemCPUCpufreqStats, error) {
|
||||
var cpufreq = &SystemCPUCpufreqStats{}
|
||||
var g errgroup.Group
|
||||
|
||||
cpus, err := filepath.Glob(fs.Path("devices/system/cpu/cpu[0-9]*"))
|
||||
if err != nil {
|
||||
return []SystemCPUCpufreqStats{}, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
systemCpufreq := []SystemCPUCpufreqStats{}
|
||||
for _, cpu := range cpus {
|
||||
cpuName := filepath.Base(cpu)
|
||||
cpuNum := strings.TrimPrefix(cpuName, "cpu")
|
||||
systemCpufreq := make([]SystemCPUCpufreqStats, len(cpus))
|
||||
for i, cpu := range cpus {
|
||||
cpuName := strings.TrimPrefix(filepath.Base(cpu), "cpu")
|
||||
|
||||
cpuCpufreqPath := filepath.Join(cpu, "cpufreq")
|
||||
if _, err := os.Stat(cpuCpufreqPath); os.IsNotExist(err) {
|
||||
continue
|
||||
}
|
||||
if err != nil {
|
||||
return []SystemCPUCpufreqStats{}, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
cpufreq, err = parseCpufreqCpuinfo(cpuCpufreqPath)
|
||||
if err != nil {
|
||||
return []SystemCPUCpufreqStats{}, err
|
||||
}
|
||||
cpufreq.Name = cpuNum
|
||||
systemCpufreq = append(systemCpufreq, *cpufreq)
|
||||
// Execute the parsing of each CPU in parallel.
|
||||
// This is done because the kernel intentionally delays access to each CPU by
|
||||
// 50 milliseconds to avoid DDoSing possibly expensive functions.
|
||||
i := i // https://golang.org/doc/faq#closures_and_goroutines
|
||||
g.Go(func() error {
|
||||
cpufreq, err := parseCpufreqCpuinfo(cpuCpufreqPath)
|
||||
if err == nil {
|
||||
cpufreq.Name = cpuName
|
||||
systemCpufreq[i] = *cpufreq
|
||||
}
|
||||
return err
|
||||
})
|
||||
}
|
||||
|
||||
if err = g.Wait(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return systemCpufreq, nil
|
||||
|
|
@ -138,7 +149,7 @@ func parseCpufreqCpuinfo(cpuPath string) (*SystemCPUCpufreqStats, error) {
|
|||
ScalingMinimumFrequency: uintOut[6],
|
||||
AvailableGovernors: stringOut[0],
|
||||
Driver: stringOut[1],
|
||||
Govenor: stringOut[2],
|
||||
Governor: stringOut[2],
|
||||
RelatedCpus: stringOut[3],
|
||||
SetSpeed: stringOut[4],
|
||||
}, nil
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue