mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-14 18:53:35 +00:00
rebase: update kubernetes to v1.20.0
updated kubernetes packages to latest release. Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
committed by
mergify[bot]
parent
4abe128bd8
commit
83559144b1
go.modgo.summodules.txt
vendor
github.com
aws
aws-sdk-go
LICENSE.txtNOTICE.txttypes.gourl.gourl_1_7.goversion.go
aws
awserr
awsutil
client
config.gocontext_1_5.gocontext_1_9.gocontext_background_1_5.gocontext_background_1_7.gocontext_sleep.goconvert_types.gocredentials
chain_provider.gocontext_background_go1.5.gocontext_background_go1.7.gocontext_go1.5.gocontext_go1.9.gocredentials.goenv_provider.goexample.inishared_credentials_provider.gostatic_provider.go
doc.goendpoints
decode.godefaults.godep_service_ids.godoc.goendpoints.golegacy_regions.gov3model.gov3model_codegen.go
errors.gojsonvalue.gologger.gorequest
connection_reset_error.gohandlers.gohttp_request.gooffset_reader.gorequest.gorequest_1_7.gorequest_1_8.gorequest_context.gorequest_context_1_6.gorequest_pagination.goretryer.gotimeout_read_closer.govalidation.gowaiter.go
signer
v4
internal
context
ini
ast.gocomma_token.gocomment_token.godoc.goempty_token.goexpression.gofuzz.goini.goini_lexer.goini_parser.goliteral_tokens.gonewline_token.gonumber_helper.goop_tokens.goparse_error.goparse_stack.gosep_tokens.goskipper.gostatement.govalue_util.govisitor.gowalker.gows_token.go
sdkio
sdkmath
sdkrand
shareddefaults
strings
sync
singleflight
private
protocol
service
blang
coreos
go-systemd
pkg
evanphx
gogo
protobuf
gogoproto
protoc-gen-gogo
golang
protobuf
proto
google
googleapis
gnostic
compiler
extensions
openapiv2
jmespath
go-jmespath
json-iterator
go
pmezard
go-difflib
prometheus
client_golang
prometheus
common
model
procfs
.golangci.ymlCODE_OF_CONDUCT.mdMakefile.commoncpuinfo.gocpuinfo_armx.gocpuinfo_mipsx.gocpuinfo_others.gocpuinfo_ppcx.gocpuinfo_s390x.gocpuinfo_x86.gocrypto.gofixtures.ttarfscache.gogo.modgo.sumkernel_random.goloadavg.gomdstat.gomountinfo.gomountstats.gonet_conntrackstat.gonet_softnet.gonet_udp.gonet_unix.goproc.goproc_cgroup.goproc_fdinfo.goproc_maps.goproc_smaps.goproc_status.goswaps.go
internal
util
stretchr
go.etcd.io
etcd
NOTICE
auth
authpb
clientv3
README.mdauth.go
balancer
client.gocluster.gocompact_op.gocompare.goconfig.gocredentials
doc.gokv.golease.gologger.gomaintenance.goop.gooptions.goretry.goretry_interceptor.gosort.gotxn.goutils.gowatch.goetcdserver
api
v3rpc
rpctypes
etcdserverpb
mvcc
pkg
logutil
discard_logger.golog_level.gologger.gomerge_logger.gopackage_logger.gozap.gozap_grpc.gozap_journal.gozap_raft.go
systemd
types
raft
go.uber.org
atomic
.codecov.yml.gitignore.travis.ymlLICENSE.txtMakefileREADME.mdatomic.goerror.goglide.lockglide.yamlstring.go
multierr
.codecov.yml.gitignore.travis.ymlCHANGELOG.mdLICENSE.txtMakefileREADME.mderror.goglide.lockglide.yaml
zap
.codecov.yml.gitignore.readme.tmpl.travis.ymlCHANGELOG.mdCODE_OF_CONDUCT.mdCONTRIBUTING.mdFAQ.mdLICENSE.txtMakefileREADME.mdarray.go
buffer
check_license.shconfig.godoc.goencoder.goerror.gofield.goflag.goglide.lockglide.yamlglobal.goglobal_go112.goglobal_prego112.gohttp_handler.gointernal
level.gologger.gooptions.gosink.gostacktrace.gosugar.gotime.gowriter.gozapcore
golang.org
x
crypto
net
html
http2
idna
websocket
oauth2
sys
cpu
byteorder.gocpu.gocpu_aix.gocpu_arm.gocpu_arm64.gocpu_linux.gocpu_linux_mips64x.gocpu_linux_ppc64x.gocpu_linux_s390x.gocpu_mips64x.gocpu_mipsx.gocpu_netbsd_arm64.gocpu_other_arm.gocpu_other_arm64.gocpu_other_mips64x.gocpu_ppc64x.gocpu_riscv64.gocpu_s390x.gocpu_wasm.gocpu_x86.gocpu_zos.gocpu_zos_s390x.go
unix
asm_openbsd_mips64.sfcntl_darwin.gofcntl_linux_32bit.gogccgo.gogccgo_c.cioctl.gomkall.shmkerrors.shsockcmsg_unix_other.gosyscall.gosyscall_aix.gosyscall_bsd.gosyscall_darwin.1_12.gosyscall_darwin.gosyscall_darwin_386.1_11.gosyscall_darwin_386.gosyscall_darwin_amd64.1_11.gosyscall_darwin_amd64.gosyscall_darwin_arm.1_11.gosyscall_darwin_arm.gosyscall_darwin_arm64.1_11.gosyscall_darwin_arm64.gosyscall_dragonfly.gosyscall_freebsd.gosyscall_illumos.gosyscall_linux.gosyscall_linux_386.gosyscall_linux_arm.gosyscall_linux_gc_arm.gosyscall_netbsd.gosyscall_openbsd.gosyscall_openbsd_mips64.gosyscall_solaris.gozerrors_darwin_386.gozerrors_darwin_amd64.gozerrors_darwin_arm.gozerrors_darwin_arm64.gozerrors_dragonfly_amd64.gozerrors_freebsd_386.gozerrors_freebsd_amd64.gozerrors_freebsd_arm.gozerrors_freebsd_arm64.gozerrors_linux.gozerrors_linux_386.gozerrors_linux_amd64.gozerrors_linux_arm.gozerrors_linux_arm64.gozerrors_linux_mips.gozerrors_linux_mips64.gozerrors_linux_mips64le.gozerrors_linux_mipsle.gozerrors_linux_ppc64.gozerrors_linux_ppc64le.gozerrors_linux_riscv64.gozerrors_linux_s390x.gozerrors_linux_sparc64.gozerrors_netbsd_386.gozerrors_netbsd_amd64.gozerrors_netbsd_arm.gozerrors_netbsd_arm64.gozerrors_openbsd_386.gozerrors_openbsd_amd64.gozerrors_openbsd_arm.gozerrors_openbsd_arm64.gozerrors_openbsd_mips64.gozerrors_solaris_amd64.gozsyscall_darwin_386.1_11.gozsyscall_darwin_386.gozsyscall_darwin_386.szsyscall_darwin_amd64.1_11.gozsyscall_darwin_amd64.gozsyscall_darwin_amd64.szsyscall_darwin_arm.1_11.gozsyscall_darwin_arm.gozsyscall_darwin_arm.szsyscall_darwin_arm64.gozsyscall_darwin_arm64.szsyscall_dragonfly_amd64.gozsyscall_illumos_amd64.gozsyscall_linux.gozsyscall_openbsd_mips64.gozsysctl_openbsd_mips64.gozsysnum_darwin_386.gozsysnum_darwin_amd64.gozsysnum_darwin_arm.gozsysnum_darwin_arm64.gozsysnum_dragonfly_amd64.gozsysnum_linux_386.gozsysnum_linux_amd64.gozsysnum_linux_arm.gozsysnum_linux_arm64.gozsysnum_linux_mips.gozsysnum_linux_mips64.gozsysnum_linux_mips64le.gozsysnum_linux_mipsle.gozsysnum_linux_ppc64.gozsysnum_linux_ppc64le.gozsysnum_linux_riscv64.gozsysnum_linux_s390x.gozsysnum_linux_sparc64.gozsysnum_openbsd_mips64.goztypes_darwin_386.goztypes_darwin_amd64.goztypes_darwin_arm.goztypes_darwin_arm64.goztypes_dragonfly_amd64.goztypes_freebsd_arm.goztypes_linux.goztypes_linux_386.goztypes_linux_amd64.goztypes_linux_arm.goztypes_linux_arm64.goztypes_linux_mips.goztypes_linux_mips64.goztypes_linux_mips64le.goztypes_linux_mipsle.goztypes_linux_ppc64.goztypes_linux_ppc64le.goztypes_linux_riscv64.goztypes_linux_s390x.goztypes_linux_sparc64.goztypes_openbsd_mips64.goztypes_solaris_amd64.go
windows
text
encoding
unicode
internal
language
transform
unicode
time
rate
google.golang.org
appengine
internal
genproto
googleapis
rpc
status
grpc
resolver
k8s.io
api
admission
v1
v1beta1
admissionregistration
v1
v1beta1
apiserverinternal
v1alpha1
apps
v1
v1beta1
v1beta2
auditregistration
v1alpha1
authentication
authorization
autoscaling
v1
v2beta1
doc.gogenerated.pb.gogenerated.prototypes.gotypes_swagger_doc_generated.gozz_generated.deepcopy.gozz_generated.prerelease-lifecycle.go
v2beta2
batch
v1
v1beta1
v2alpha1
certificates
v1
doc.gogenerated.pb.gogenerated.protoregister.gotypes.gotypes_swagger_doc_generated.gozz_generated.deepcopy.go
v1beta1
coordination
core
v1
discovery
v1alpha1
v1beta1
events
v1
doc.gogenerated.pb.gogenerated.protoregister.gotypes.gotypes_swagger_doc_generated.gozz_generated.deepcopy.go
v1beta1
extensions
v1beta1
flowcontrol
v1alpha1
v1beta1
networking
v1
generated.pb.gogenerated.protoregister.gotypes.gotypes_swagger_doc_generated.gozz_generated.deepcopy.go
v1beta1
node
v1
doc.gogenerated.pb.gogenerated.protoregister.gotypes.gotypes_swagger_doc_generated.gozz_generated.deepcopy.go
v1alpha1
v1beta1
policy
v1beta1
rbac
v1
v1alpha1
v1beta1
scheduling
v1
v1alpha1
v1beta1
settings
storage
apimachinery
pkg
api
errors
meta
resource
validation
apis
meta
conversion
fields
labels
runtime
types
util
cache
clock
errors
framer
httpstream
intstr
json
net
runtime
strategicpatch
validation
version
wait
yaml
watch
third_party
forked
golang
reflect
apiserver
pkg
admission
apis
apiserver
audit
audit
authentication
endpoints
features
quota
server
egressselector
storage
OWNERSerrors.go
etcd3
OWNERSapi_object_versioner.gocompact.goerrors.goevent.gohealthcheck.golease_manager.gologger.go
interfaces.goselection_predicate.goutil.gometrics
store.gowatcher.govalue
util
webhook
warning
client-go
discovery
informers
kubernetes
clientset.go
scheme
typed
apiserverinternal
auditregistration
v1alpha1
certificates
core
events
flowcontrol
networking
node
settings
v1alpha1
storage
listers
admissionregistration
v1
v1beta1
apiserverinternal
apps
v1
v1beta1
v1beta2
auditregistration
v1alpha1
autoscaling
batch
certificates
coordination
core
v1
discovery
events
extensions
flowcontrol
v1alpha1
v1beta1
networking
node
policy
rbac
v1
v1alpha1
v1beta1
scheduling
settings
v1alpha1
storage
metadata
pkg
apis
plugin
pkg
client
auth
exec
rest
restmapper
tools
auth
cache
OWNERScontroller.godelta_fifo.goexpiration_cache.gofifo.golisters.gomutation_cache.gomutation_detector.goreflector.goshared_informer.go
clientcmd
leaderelection
metrics
record
remotecommand
watch
transport
util
cloud-provider
component-base
cli
config
featuregate
metrics
counter.godesc.gohttp.goregistry.go
legacyregistry
metric.gooptions.goopts.goprocessstarttime.goprometheus
ratelimiter
testutil
version.gocontroller-manager
cri-api
pkg
apis
runtime
v1alpha2
csi-translation-lib
klog
kube-openapi
pkg
util
kube-scheduler
extender
kubectl
pkg
kubelet
kubernetes
pkg
api
apis
apps
autoscaling
batch
core
OWNERSannotation_key_constants.go
helper
install
pods
resource.gotypes.gov1
validation
zz_generated.deepcopy.goextensions
networking
policy
scheduling
storage
v1
util
cluster
controller
.import-restrictionsBUILDOWNERSclient_builder_dynamic.gocontroller_ref_manager.gocontroller_utils.go
deployment
informer_factory.gonodelifecycle
util
volume
persistentvolume
scheduling
features
kubelet
apis
container
BUILDcache.gocontainer_gc.gocontainer_reference_manager.gohelpers.goos.goref.goresize.goruntime.goruntime_cache.goruntime_cache_fake.gosync_result.go
dockershim
metrics
events
lifecycle
metrics
sysctl
types
util
format
proxy
scheduler
apis
framework
plugins
helper
nodeaffinity
nodename
nodeports
noderesources
v1alpha1
listers
metrics
nodeinfo
util
security
serviceaccount
ssh
util
node
parsers
resizefs
sysctl
volume
BUILDOWNERSnoop_expandable_plugin.goplugins.go
util
BUILDOWNERSatomic_writer.goattach_limit.godevice_util.godevice_util_linux.godevice_util_unsupported.godoc.go
volume.govolume_linux.govolume_unsupported.gofs
fsquota
hostutil
io_util.gometrics.gonested_volumes.gorecyclerclient
resize_util.gosubpath
types
util.govolumepathhandler
test
e2e
framework
.import-restrictionsBUILDcleanup.goexec_util.goframework.gogoogle_compute.go
kubectl
log.golog
log_size_monitoring.gometrics
node
nodes_util.gopod
pods.goports.gopsp.gopv
resource
resource_usage_gatherer.goskipper
ssh
test_context.gotestfiles
util.gostorage
system
utils
third_party
mount-utils
LICENSEOWNERSREADME.mdSECURITY_CONTACTScode-of-conduct.mddoc.gofake_mounter.gogo.modgo.summount.gomount_helper_common.gomount_helper_unix.gomount_helper_windows.gomount_linux.gomount_unsupported.gomount_windows.go
utils
sigs.k8s.io
apiserver-network-proxy
structured-merge-diff
2
vendor/github.com/prometheus/client_golang/prometheus/counter.go
generated
vendored
2
vendor/github.com/prometheus/client_golang/prometheus/counter.go
generated
vendored
@ -309,6 +309,8 @@ type CounterFunc interface {
|
||||
// provided function must be concurrency-safe. The function should also honor
|
||||
// the contract for a Counter (values only go up, not down), but compliance will
|
||||
// not be checked.
|
||||
//
|
||||
// Check out the ExampleGaugeFunc examples for the similar GaugeFunc.
|
||||
func NewCounterFunc(opts CounterOpts, function func() float64) CounterFunc {
|
||||
return newValueFunc(NewDesc(
|
||||
BuildFQName(opts.Namespace, opts.Subsystem, opts.Name),
|
||||
|
1
vendor/github.com/prometheus/client_golang/prometheus/desc.go
generated
vendored
1
vendor/github.com/prometheus/client_golang/prometheus/desc.go
generated
vendored
@ -20,6 +20,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/cespare/xxhash/v2"
|
||||
//lint:ignore SA1019 Need to keep deprecated package for compatibility.
|
||||
"github.com/golang/protobuf/proto"
|
||||
"github.com/prometheus/common/model"
|
||||
|
||||
|
3
vendor/github.com/prometheus/client_golang/prometheus/histogram.go
generated
vendored
3
vendor/github.com/prometheus/client_golang/prometheus/histogram.go
generated
vendored
@ -22,6 +22,7 @@ import (
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
//lint:ignore SA1019 Need to keep deprecated package for compatibility.
|
||||
"github.com/golang/protobuf/proto"
|
||||
|
||||
dto "github.com/prometheus/client_model/go"
|
||||
@ -606,7 +607,7 @@ func NewConstHistogram(
|
||||
}
|
||||
|
||||
// MustNewConstHistogram is a version of NewConstHistogram that panics where
|
||||
// NewConstMetric would have returned an error.
|
||||
// NewConstHistogram would have returned an error.
|
||||
func MustNewConstHistogram(
|
||||
desc *Desc,
|
||||
count uint64,
|
||||
|
1
vendor/github.com/prometheus/client_golang/prometheus/metric.go
generated
vendored
1
vendor/github.com/prometheus/client_golang/prometheus/metric.go
generated
vendored
@ -17,6 +17,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
//lint:ignore SA1019 Need to keep deprecated package for compatibility.
|
||||
"github.com/golang/protobuf/proto"
|
||||
"github.com/prometheus/common/model"
|
||||
|
||||
|
24
vendor/github.com/prometheus/client_golang/prometheus/process_collector_windows.go
generated
vendored
24
vendor/github.com/prometheus/client_golang/prometheus/process_collector_windows.go
generated
vendored
@ -33,18 +33,22 @@ var (
|
||||
)
|
||||
|
||||
type processMemoryCounters struct {
|
||||
// https://docs.microsoft.com/en-us/windows/desktop/api/psapi/ns-psapi-_process_memory_counters_ex
|
||||
// System interface description
|
||||
// https://docs.microsoft.com/en-us/windows/desktop/api/psapi/ns-psapi-process_memory_counters_ex
|
||||
|
||||
// Refer to the Golang internal implementation
|
||||
// https://golang.org/src/internal/syscall/windows/psapi_windows.go
|
||||
_ uint32
|
||||
PageFaultCount uint32
|
||||
PeakWorkingSetSize uint64
|
||||
WorkingSetSize uint64
|
||||
QuotaPeakPagedPoolUsage uint64
|
||||
QuotaPagedPoolUsage uint64
|
||||
QuotaPeakNonPagedPoolUsage uint64
|
||||
QuotaNonPagedPoolUsage uint64
|
||||
PagefileUsage uint64
|
||||
PeakPagefileUsage uint64
|
||||
PrivateUsage uint64
|
||||
PeakWorkingSetSize uintptr
|
||||
WorkingSetSize uintptr
|
||||
QuotaPeakPagedPoolUsage uintptr
|
||||
QuotaPagedPoolUsage uintptr
|
||||
QuotaPeakNonPagedPoolUsage uintptr
|
||||
QuotaNonPagedPoolUsage uintptr
|
||||
PagefileUsage uintptr
|
||||
PeakPagefileUsage uintptr
|
||||
PrivateUsage uintptr
|
||||
}
|
||||
|
||||
func getProcessMemoryInfo(handle windows.Handle) (processMemoryCounters, error) {
|
||||
|
1
vendor/github.com/prometheus/client_golang/prometheus/registry.go
generated
vendored
1
vendor/github.com/prometheus/client_golang/prometheus/registry.go
generated
vendored
@ -26,6 +26,7 @@ import (
|
||||
"unicode/utf8"
|
||||
|
||||
"github.com/cespare/xxhash/v2"
|
||||
//lint:ignore SA1019 Need to keep deprecated package for compatibility.
|
||||
"github.com/golang/protobuf/proto"
|
||||
"github.com/prometheus/common/expfmt"
|
||||
|
||||
|
1
vendor/github.com/prometheus/client_golang/prometheus/summary.go
generated
vendored
1
vendor/github.com/prometheus/client_golang/prometheus/summary.go
generated
vendored
@ -23,6 +23,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/beorn7/perks/quantile"
|
||||
//lint:ignore SA1019 Need to keep deprecated package for compatibility.
|
||||
"github.com/golang/protobuf/proto"
|
||||
|
||||
dto "github.com/prometheus/client_model/go"
|
||||
|
46
vendor/github.com/prometheus/client_golang/prometheus/testutil/lint.go
generated
vendored
Normal file
46
vendor/github.com/prometheus/client_golang/prometheus/testutil/lint.go
generated
vendored
Normal file
@ -0,0 +1,46 @@
|
||||
// Copyright 2020 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 testutil
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/client_golang/prometheus/testutil/promlint"
|
||||
)
|
||||
|
||||
// CollectAndLint registers the provided Collector with a newly created pedantic
|
||||
// Registry. It then calls GatherAndLint with that Registry and with the
|
||||
// provided metricNames.
|
||||
func CollectAndLint(c prometheus.Collector, metricNames ...string) ([]promlint.Problem, error) {
|
||||
reg := prometheus.NewPedanticRegistry()
|
||||
if err := reg.Register(c); err != nil {
|
||||
return nil, fmt.Errorf("registering collector failed: %s", err)
|
||||
}
|
||||
return GatherAndLint(reg, metricNames...)
|
||||
}
|
||||
|
||||
// GatherAndLint gathers all metrics from the provided Gatherer and checks them
|
||||
// with the linter in the promlint package. If any metricNames are provided,
|
||||
// only metrics with those names are checked.
|
||||
func GatherAndLint(g prometheus.Gatherer, metricNames ...string) ([]promlint.Problem, error) {
|
||||
got, err := g.Gather()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("gathering metrics failed: %s", err)
|
||||
}
|
||||
if metricNames != nil {
|
||||
got = filterMetrics(got, metricNames)
|
||||
}
|
||||
return promlint.NewWithMetricFamilies(got).Lint()
|
||||
}
|
386
vendor/github.com/prometheus/client_golang/prometheus/testutil/promlint/promlint.go
generated
vendored
Normal file
386
vendor/github.com/prometheus/client_golang/prometheus/testutil/promlint/promlint.go
generated
vendored
Normal file
@ -0,0 +1,386 @@
|
||||
// Copyright 2020 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 promlint provides a linter for Prometheus metrics.
|
||||
package promlint
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"regexp"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/prometheus/common/expfmt"
|
||||
|
||||
dto "github.com/prometheus/client_model/go"
|
||||
)
|
||||
|
||||
// A Linter is a Prometheus metrics linter. It identifies issues with metric
|
||||
// names, types, and metadata, and reports them to the caller.
|
||||
type Linter struct {
|
||||
// The linter will read metrics in the Prometheus text format from r and
|
||||
// then lint it, _and_ it will lint the metrics provided directly as
|
||||
// MetricFamily proto messages in mfs. Note, however, that the current
|
||||
// constructor functions New and NewWithMetricFamilies only ever set one
|
||||
// of them.
|
||||
r io.Reader
|
||||
mfs []*dto.MetricFamily
|
||||
}
|
||||
|
||||
// A Problem is an issue detected by a Linter.
|
||||
type Problem struct {
|
||||
// The name of the metric indicated by this Problem.
|
||||
Metric string
|
||||
|
||||
// A description of the issue for this Problem.
|
||||
Text string
|
||||
}
|
||||
|
||||
// newProblem is helper function to create a Problem.
|
||||
func newProblem(mf *dto.MetricFamily, text string) Problem {
|
||||
return Problem{
|
||||
Metric: mf.GetName(),
|
||||
Text: text,
|
||||
}
|
||||
}
|
||||
|
||||
// New creates a new Linter that reads an input stream of Prometheus metrics in
|
||||
// the Prometheus text exposition format.
|
||||
func New(r io.Reader) *Linter {
|
||||
return &Linter{
|
||||
r: r,
|
||||
}
|
||||
}
|
||||
|
||||
// NewWithMetricFamilies creates a new Linter that reads from a slice of
|
||||
// MetricFamily protobuf messages.
|
||||
func NewWithMetricFamilies(mfs []*dto.MetricFamily) *Linter {
|
||||
return &Linter{
|
||||
mfs: mfs,
|
||||
}
|
||||
}
|
||||
|
||||
// Lint performs a linting pass, returning a slice of Problems indicating any
|
||||
// issues found in the metrics stream. The slice is sorted by metric name
|
||||
// and issue description.
|
||||
func (l *Linter) Lint() ([]Problem, error) {
|
||||
var problems []Problem
|
||||
|
||||
if l.r != nil {
|
||||
d := expfmt.NewDecoder(l.r, expfmt.FmtText)
|
||||
|
||||
mf := &dto.MetricFamily{}
|
||||
for {
|
||||
if err := d.Decode(mf); err != nil {
|
||||
if err == io.EOF {
|
||||
break
|
||||
}
|
||||
|
||||
return nil, err
|
||||
}
|
||||
|
||||
problems = append(problems, lint(mf)...)
|
||||
}
|
||||
}
|
||||
for _, mf := range l.mfs {
|
||||
problems = append(problems, lint(mf)...)
|
||||
}
|
||||
|
||||
// Ensure deterministic output.
|
||||
sort.SliceStable(problems, func(i, j int) bool {
|
||||
if problems[i].Metric == problems[j].Metric {
|
||||
return problems[i].Text < problems[j].Text
|
||||
}
|
||||
return problems[i].Metric < problems[j].Metric
|
||||
})
|
||||
|
||||
return problems, nil
|
||||
}
|
||||
|
||||
// lint is the entry point for linting a single metric.
|
||||
func lint(mf *dto.MetricFamily) []Problem {
|
||||
fns := []func(mf *dto.MetricFamily) []Problem{
|
||||
lintHelp,
|
||||
lintMetricUnits,
|
||||
lintCounter,
|
||||
lintHistogramSummaryReserved,
|
||||
lintMetricTypeInName,
|
||||
lintReservedChars,
|
||||
lintCamelCase,
|
||||
lintUnitAbbreviations,
|
||||
}
|
||||
|
||||
var problems []Problem
|
||||
for _, fn := range fns {
|
||||
problems = append(problems, fn(mf)...)
|
||||
}
|
||||
|
||||
// TODO(mdlayher): lint rules for specific metrics types.
|
||||
return problems
|
||||
}
|
||||
|
||||
// lintHelp detects issues related to the help text for a metric.
|
||||
func lintHelp(mf *dto.MetricFamily) []Problem {
|
||||
var problems []Problem
|
||||
|
||||
// Expect all metrics to have help text available.
|
||||
if mf.Help == nil {
|
||||
problems = append(problems, newProblem(mf, "no help text"))
|
||||
}
|
||||
|
||||
return problems
|
||||
}
|
||||
|
||||
// lintMetricUnits detects issues with metric unit names.
|
||||
func lintMetricUnits(mf *dto.MetricFamily) []Problem {
|
||||
var problems []Problem
|
||||
|
||||
unit, base, ok := metricUnits(*mf.Name)
|
||||
if !ok {
|
||||
// No known units detected.
|
||||
return nil
|
||||
}
|
||||
|
||||
// Unit is already a base unit.
|
||||
if unit == base {
|
||||
return nil
|
||||
}
|
||||
|
||||
problems = append(problems, newProblem(mf, fmt.Sprintf("use base unit %q instead of %q", base, unit)))
|
||||
|
||||
return problems
|
||||
}
|
||||
|
||||
// lintCounter detects issues specific to counters, as well as patterns that should
|
||||
// only be used with counters.
|
||||
func lintCounter(mf *dto.MetricFamily) []Problem {
|
||||
var problems []Problem
|
||||
|
||||
isCounter := mf.GetType() == dto.MetricType_COUNTER
|
||||
isUntyped := mf.GetType() == dto.MetricType_UNTYPED
|
||||
hasTotalSuffix := strings.HasSuffix(mf.GetName(), "_total")
|
||||
|
||||
switch {
|
||||
case isCounter && !hasTotalSuffix:
|
||||
problems = append(problems, newProblem(mf, `counter metrics should have "_total" suffix`))
|
||||
case !isUntyped && !isCounter && hasTotalSuffix:
|
||||
problems = append(problems, newProblem(mf, `non-counter metrics should not have "_total" suffix`))
|
||||
}
|
||||
|
||||
return problems
|
||||
}
|
||||
|
||||
// lintHistogramSummaryReserved detects when other types of metrics use names or labels
|
||||
// reserved for use by histograms and/or summaries.
|
||||
func lintHistogramSummaryReserved(mf *dto.MetricFamily) []Problem {
|
||||
// These rules do not apply to untyped metrics.
|
||||
t := mf.GetType()
|
||||
if t == dto.MetricType_UNTYPED {
|
||||
return nil
|
||||
}
|
||||
|
||||
var problems []Problem
|
||||
|
||||
isHistogram := t == dto.MetricType_HISTOGRAM
|
||||
isSummary := t == dto.MetricType_SUMMARY
|
||||
|
||||
n := mf.GetName()
|
||||
|
||||
if !isHistogram && strings.HasSuffix(n, "_bucket") {
|
||||
problems = append(problems, newProblem(mf, `non-histogram metrics should not have "_bucket" suffix`))
|
||||
}
|
||||
if !isHistogram && !isSummary && strings.HasSuffix(n, "_count") {
|
||||
problems = append(problems, newProblem(mf, `non-histogram and non-summary metrics should not have "_count" suffix`))
|
||||
}
|
||||
if !isHistogram && !isSummary && strings.HasSuffix(n, "_sum") {
|
||||
problems = append(problems, newProblem(mf, `non-histogram and non-summary metrics should not have "_sum" suffix`))
|
||||
}
|
||||
|
||||
for _, m := range mf.GetMetric() {
|
||||
for _, l := range m.GetLabel() {
|
||||
ln := l.GetName()
|
||||
|
||||
if !isHistogram && ln == "le" {
|
||||
problems = append(problems, newProblem(mf, `non-histogram metrics should not have "le" label`))
|
||||
}
|
||||
if !isSummary && ln == "quantile" {
|
||||
problems = append(problems, newProblem(mf, `non-summary metrics should not have "quantile" label`))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return problems
|
||||
}
|
||||
|
||||
// lintMetricTypeInName detects when metric types are included in the metric name.
|
||||
func lintMetricTypeInName(mf *dto.MetricFamily) []Problem {
|
||||
var problems []Problem
|
||||
n := strings.ToLower(mf.GetName())
|
||||
|
||||
for i, t := range dto.MetricType_name {
|
||||
if i == int32(dto.MetricType_UNTYPED) {
|
||||
continue
|
||||
}
|
||||
|
||||
typename := strings.ToLower(t)
|
||||
if strings.Contains(n, "_"+typename+"_") || strings.HasSuffix(n, "_"+typename) {
|
||||
problems = append(problems, newProblem(mf, fmt.Sprintf(`metric name should not include type '%s'`, typename)))
|
||||
}
|
||||
}
|
||||
return problems
|
||||
}
|
||||
|
||||
// lintReservedChars detects colons in metric names.
|
||||
func lintReservedChars(mf *dto.MetricFamily) []Problem {
|
||||
var problems []Problem
|
||||
if strings.Contains(mf.GetName(), ":") {
|
||||
problems = append(problems, newProblem(mf, "metric names should not contain ':'"))
|
||||
}
|
||||
return problems
|
||||
}
|
||||
|
||||
var camelCase = regexp.MustCompile(`[a-z][A-Z]`)
|
||||
|
||||
// lintCamelCase detects metric names and label names written in camelCase.
|
||||
func lintCamelCase(mf *dto.MetricFamily) []Problem {
|
||||
var problems []Problem
|
||||
if camelCase.FindString(mf.GetName()) != "" {
|
||||
problems = append(problems, newProblem(mf, "metric names should be written in 'snake_case' not 'camelCase'"))
|
||||
}
|
||||
|
||||
for _, m := range mf.GetMetric() {
|
||||
for _, l := range m.GetLabel() {
|
||||
if camelCase.FindString(l.GetName()) != "" {
|
||||
problems = append(problems, newProblem(mf, "label names should be written in 'snake_case' not 'camelCase'"))
|
||||
}
|
||||
}
|
||||
}
|
||||
return problems
|
||||
}
|
||||
|
||||
// lintUnitAbbreviations detects abbreviated units in the metric name.
|
||||
func lintUnitAbbreviations(mf *dto.MetricFamily) []Problem {
|
||||
var problems []Problem
|
||||
n := strings.ToLower(mf.GetName())
|
||||
for _, s := range unitAbbreviations {
|
||||
if strings.Contains(n, "_"+s+"_") || strings.HasSuffix(n, "_"+s) {
|
||||
problems = append(problems, newProblem(mf, "metric names should not contain abbreviated units"))
|
||||
}
|
||||
}
|
||||
return problems
|
||||
}
|
||||
|
||||
// metricUnits attempts to detect known unit types used as part of a metric name,
|
||||
// e.g. "foo_bytes_total" or "bar_baz_milligrams".
|
||||
func metricUnits(m string) (unit string, base string, ok bool) {
|
||||
ss := strings.Split(m, "_")
|
||||
|
||||
for unit, base := range units {
|
||||
// Also check for "no prefix".
|
||||
for _, p := range append(unitPrefixes, "") {
|
||||
for _, s := range ss {
|
||||
// Attempt to explicitly match a known unit with a known prefix,
|
||||
// as some words may look like "units" when matching suffix.
|
||||
//
|
||||
// As an example, "thermometers" should not match "meters", but
|
||||
// "kilometers" should.
|
||||
if s == p+unit {
|
||||
return p + unit, base, true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return "", "", false
|
||||
}
|
||||
|
||||
// Units and their possible prefixes recognized by this library. More can be
|
||||
// added over time as needed.
|
||||
var (
|
||||
// map a unit to the appropriate base unit.
|
||||
units = map[string]string{
|
||||
// Base units.
|
||||
"amperes": "amperes",
|
||||
"bytes": "bytes",
|
||||
"celsius": "celsius", // Also allow Celsius because it is common in typical Prometheus use cases.
|
||||
"grams": "grams",
|
||||
"joules": "joules",
|
||||
"kelvin": "kelvin", // SI base unit, used in special cases (e.g. color temperature, scientific measurements).
|
||||
"meters": "meters", // Both American and international spelling permitted.
|
||||
"metres": "metres",
|
||||
"seconds": "seconds",
|
||||
"volts": "volts",
|
||||
|
||||
// Non base units.
|
||||
// Time.
|
||||
"minutes": "seconds",
|
||||
"hours": "seconds",
|
||||
"days": "seconds",
|
||||
"weeks": "seconds",
|
||||
// Temperature.
|
||||
"kelvins": "kelvin",
|
||||
"fahrenheit": "celsius",
|
||||
"rankine": "celsius",
|
||||
// Length.
|
||||
"inches": "meters",
|
||||
"yards": "meters",
|
||||
"miles": "meters",
|
||||
// Bytes.
|
||||
"bits": "bytes",
|
||||
// Energy.
|
||||
"calories": "joules",
|
||||
// Mass.
|
||||
"pounds": "grams",
|
||||
"ounces": "grams",
|
||||
}
|
||||
|
||||
unitPrefixes = []string{
|
||||
"pico",
|
||||
"nano",
|
||||
"micro",
|
||||
"milli",
|
||||
"centi",
|
||||
"deci",
|
||||
"deca",
|
||||
"hecto",
|
||||
"kilo",
|
||||
"kibi",
|
||||
"mega",
|
||||
"mibi",
|
||||
"giga",
|
||||
"gibi",
|
||||
"tera",
|
||||
"tebi",
|
||||
"peta",
|
||||
"pebi",
|
||||
}
|
||||
|
||||
// Common abbreviations that we'd like to discourage.
|
||||
unitAbbreviations = []string{
|
||||
"s",
|
||||
"ms",
|
||||
"us",
|
||||
"ns",
|
||||
"sec",
|
||||
"b",
|
||||
"kb",
|
||||
"mb",
|
||||
"gb",
|
||||
"tb",
|
||||
"pb",
|
||||
"m",
|
||||
"h",
|
||||
"d",
|
||||
}
|
||||
)
|
66
vendor/github.com/prometheus/client_golang/prometheus/testutil/testutil.go
generated
vendored
66
vendor/github.com/prometheus/client_golang/prometheus/testutil/testutil.go
generated
vendored
@ -31,6 +31,10 @@
|
||||
// testing custom prometheus.Collector implementations and in particular whole
|
||||
// exporters, i.e. programs that retrieve telemetry data from a 3rd party source
|
||||
// and convert it into Prometheus metrics.
|
||||
//
|
||||
// In a similar pattern, CollectAndLint and GatherAndLint can be used to detect
|
||||
// metrics that have issues with their name, type, or metadata without being
|
||||
// necessarily invalid, e.g. a counter with a name missing the “_total” suffix.
|
||||
package testutil
|
||||
|
||||
import (
|
||||
@ -108,36 +112,48 @@ func ToFloat64(c prometheus.Collector) float64 {
|
||||
panic(fmt.Errorf("collected a non-gauge/counter/untyped metric: %s", pb))
|
||||
}
|
||||
|
||||
// CollectAndCount collects all Metrics from the provided Collector and returns their number.
|
||||
//
|
||||
// This can be used to assert the number of metrics collected by a given collector after certain operations.
|
||||
//
|
||||
// This function is only for testing purposes, and even for testing, other approaches
|
||||
// are often more appropriate (see this package's documentation).
|
||||
func CollectAndCount(c prometheus.Collector) int {
|
||||
var (
|
||||
mCount int
|
||||
mChan = make(chan prometheus.Metric)
|
||||
done = make(chan struct{})
|
||||
)
|
||||
// CollectAndCount registers the provided Collector with a newly created
|
||||
// pedantic Registry. It then calls GatherAndCount with that Registry and with
|
||||
// the provided metricNames. In the unlikely case that the registration or the
|
||||
// gathering fails, this function panics. (This is inconsistent with the other
|
||||
// CollectAnd… functions in this package and has historical reasons. Changing
|
||||
// the function signature would be a breaking change and will therefore only
|
||||
// happen with the next major version bump.)
|
||||
func CollectAndCount(c prometheus.Collector, metricNames ...string) int {
|
||||
reg := prometheus.NewPedanticRegistry()
|
||||
if err := reg.Register(c); err != nil {
|
||||
panic(fmt.Errorf("registering collector failed: %s", err))
|
||||
}
|
||||
result, err := GatherAndCount(reg, metricNames...)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
go func() {
|
||||
for range mChan {
|
||||
mCount++
|
||||
}
|
||||
close(done)
|
||||
}()
|
||||
// GatherAndCount gathers all metrics from the provided Gatherer and counts
|
||||
// them. It returns the number of metric children in all gathered metric
|
||||
// families together. If any metricNames are provided, only metrics with those
|
||||
// names are counted.
|
||||
func GatherAndCount(g prometheus.Gatherer, metricNames ...string) (int, error) {
|
||||
got, err := g.Gather()
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("gathering metrics failed: %s", err)
|
||||
}
|
||||
if metricNames != nil {
|
||||
got = filterMetrics(got, metricNames)
|
||||
}
|
||||
|
||||
c.Collect(mChan)
|
||||
close(mChan)
|
||||
<-done
|
||||
|
||||
return mCount
|
||||
result := 0
|
||||
for _, mf := range got {
|
||||
result += len(mf.GetMetric())
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// CollectAndCompare registers the provided Collector with a newly created
|
||||
// pedantic Registry. It then does the same as GatherAndCompare, gathering the
|
||||
// metrics from the pedantic Registry.
|
||||
// pedantic Registry. It then calls GatherAndCompare with that Registry and with
|
||||
// the provided metricNames.
|
||||
func CollectAndCompare(c prometheus.Collector, expected io.Reader, metricNames ...string) error {
|
||||
reg := prometheus.NewPedanticRegistry()
|
||||
if err := reg.Register(c); err != nil {
|
||||
|
1
vendor/github.com/prometheus/client_golang/prometheus/value.go
generated
vendored
1
vendor/github.com/prometheus/client_golang/prometheus/value.go
generated
vendored
@ -19,6 +19,7 @@ import (
|
||||
"time"
|
||||
"unicode/utf8"
|
||||
|
||||
//lint:ignore SA1019 Need to keep deprecated package for compatibility.
|
||||
"github.com/golang/protobuf/proto"
|
||||
"github.com/golang/protobuf/ptypes"
|
||||
|
||||
|
14
vendor/github.com/prometheus/client_golang/prometheus/wrap.go
generated
vendored
14
vendor/github.com/prometheus/client_golang/prometheus/wrap.go
generated
vendored
@ -17,6 +17,7 @@ import (
|
||||
"fmt"
|
||||
"sort"
|
||||
|
||||
//lint:ignore SA1019 Need to keep deprecated package for compatibility.
|
||||
"github.com/golang/protobuf/proto"
|
||||
|
||||
dto "github.com/prometheus/client_model/go"
|
||||
@ -27,7 +28,8 @@ import (
|
||||
// registered with the wrapped Registerer in a modified way. The modified
|
||||
// Collector adds the provided Labels to all Metrics it collects (as
|
||||
// ConstLabels). The Metrics collected by the unmodified Collector must not
|
||||
// duplicate any of those labels.
|
||||
// duplicate any of those labels. Wrapping a nil value is valid, resulting
|
||||
// in a no-op Registerer.
|
||||
//
|
||||
// WrapRegistererWith provides a way to add fixed labels to a subset of
|
||||
// Collectors. It should not be used to add fixed labels to all metrics exposed.
|
||||
@ -50,6 +52,7 @@ func WrapRegistererWith(labels Labels, reg Registerer) Registerer {
|
||||
// Registerer. Collectors registered with the returned Registerer will be
|
||||
// registered with the wrapped Registerer in a modified way. The modified
|
||||
// Collector adds the provided prefix to the name of all Metrics it collects.
|
||||
// Wrapping a nil value is valid, resulting in a no-op Registerer.
|
||||
//
|
||||
// WrapRegistererWithPrefix is useful to have one place to prefix all metrics of
|
||||
// a sub-system. To make this work, register metrics of the sub-system with the
|
||||
@ -80,6 +83,9 @@ type wrappingRegisterer struct {
|
||||
}
|
||||
|
||||
func (r *wrappingRegisterer) Register(c Collector) error {
|
||||
if r.wrappedRegisterer == nil {
|
||||
return nil
|
||||
}
|
||||
return r.wrappedRegisterer.Register(&wrappingCollector{
|
||||
wrappedCollector: c,
|
||||
prefix: r.prefix,
|
||||
@ -88,6 +94,9 @@ func (r *wrappingRegisterer) Register(c Collector) error {
|
||||
}
|
||||
|
||||
func (r *wrappingRegisterer) MustRegister(cs ...Collector) {
|
||||
if r.wrappedRegisterer == nil {
|
||||
return
|
||||
}
|
||||
for _, c := range cs {
|
||||
if err := r.Register(c); err != nil {
|
||||
panic(err)
|
||||
@ -96,6 +105,9 @@ func (r *wrappingRegisterer) MustRegister(cs ...Collector) {
|
||||
}
|
||||
|
||||
func (r *wrappingRegisterer) Unregister(c Collector) bool {
|
||||
if r.wrappedRegisterer == nil {
|
||||
return false
|
||||
}
|
||||
return r.wrappedRegisterer.Unregister(&wrappingCollector{
|
||||
wrappedCollector: c,
|
||||
prefix: r.prefix,
|
||||
|
Reference in New Issue
Block a user