use istio client-go library instead of knative (#1661)

use istio client-go library instead of knative
bump kubernetes dependency version
change code coverage to codecov
This commit is contained in:
zryfish
2019-12-13 11:26:18 +08:00
committed by GitHub
parent f249a6e081
commit ea88c8803d
2071 changed files with 354531 additions and 108336 deletions

View File

@@ -23,7 +23,6 @@ import (
"github.com/prometheus/client_golang/prometheus"
reflectormetrics "k8s.io/client-go/tools/cache"
clientmetrics "k8s.io/client-go/tools/metrics"
workqueuemetrics "k8s.io/client-go/util/workqueue"
)
// this file contains setup logic to initialize the myriad of places
@@ -104,64 +103,11 @@ var (
Name: "last_resource_version",
Help: "Last resource version seen for the reflectors",
}, []string{"name"})
// workqueue metrics
workQueueSubsystem = "workqueue"
depth = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Subsystem: workQueueSubsystem,
Name: "depth",
Help: "Current depth of workqueue",
}, []string{"name"})
adds = prometheus.NewCounterVec(prometheus.CounterOpts{
Subsystem: workQueueSubsystem,
Name: "adds_total",
Help: "Total number of adds handled by workqueue",
}, []string{"name"})
latency = prometheus.NewHistogramVec(prometheus.HistogramOpts{
Subsystem: workQueueSubsystem,
Name: "queue_latency_seconds",
Help: "How long in seconds an item stays in workqueue before being requested.",
Buckets: prometheus.ExponentialBuckets(10e-9, 10, 10),
}, []string{"name"})
workDuration = prometheus.NewHistogramVec(prometheus.HistogramOpts{
Subsystem: workQueueSubsystem,
Name: "work_duration_seconds",
Help: "How long in seconds processing an item from workqueue takes.",
Buckets: prometheus.ExponentialBuckets(10e-9, 10, 10),
}, []string{"name"})
retries = prometheus.NewCounterVec(prometheus.CounterOpts{
Subsystem: workQueueSubsystem,
Name: "retries_total",
Help: "Total number of retries handled by workqueue",
}, []string{"name"})
longestRunning = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Subsystem: workQueueSubsystem,
Name: "longest_running_processor_microseconds",
Help: "How many microseconds has the longest running " +
"processor for workqueue been running.",
}, []string{"name"})
unfinishedWork = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Subsystem: workQueueSubsystem,
Name: "unfinished_work_seconds",
Help: "How many seconds of work has done that " +
"is in progress and hasn't been observed by work_duration. Large " +
"values indicate stuck threads. One can deduce the number of stuck " +
"threads by observing the rate at which this increases.",
}, []string{"name"})
)
func init() {
registerClientMetrics()
registerReflectorMetrics()
registerWorkqueueMetrics()
}
// registerClientMetrics sets up the client latency metrics from client-go
@@ -174,7 +120,7 @@ func registerClientMetrics() {
clientmetrics.Register(&latencyAdapter{metric: requestLatency}, &resultAdapter{metric: requestResult})
}
// registerReflectorMetrics sets up reflector (reconile) loop metrics
// registerReflectorMetrics sets up reflector (reconcile) loop metrics
func registerReflectorMetrics() {
Registry.MustRegister(listsTotal)
Registry.MustRegister(listsDuration)
@@ -188,20 +134,7 @@ func registerReflectorMetrics() {
reflectormetrics.SetReflectorMetricsProvider(reflectorMetricsProvider{})
}
// registerWorkQueueMetrics sets up workqueue (other reconcile) metrics
func registerWorkqueueMetrics() {
Registry.MustRegister(depth)
Registry.MustRegister(adds)
Registry.MustRegister(latency)
Registry.MustRegister(workDuration)
Registry.MustRegister(retries)
Registry.MustRegister(longestRunning)
Registry.MustRegister(unfinishedWork)
workqueuemetrics.SetProvider(workqueueMetricsProvider{})
}
// this section contains adapters, implementations, and other sundry organic, artisinally
// this section contains adapters, implementations, and other sundry organic, artisanally
// hand-crafted syntax trees required to convince client-go that it actually wants to let
// someone use its metrics.
@@ -262,38 +195,3 @@ func (reflectorMetricsProvider) NewItemsInWatchMetric(name string) reflectormetr
func (reflectorMetricsProvider) NewLastResourceVersionMetric(name string) reflectormetrics.GaugeMetric {
return lastResourceVersion.WithLabelValues(name)
}
// Workqueue metrics (method #3 for client-go metrics),
// copied (more-or-less directly) from k8s.io/kubernetes setup code
// (which isn't anywhere in an easily-importable place).
// TODO(directxman12): stop "cheating" and calling histograms summaries when we pull in the latest deps
type workqueueMetricsProvider struct{}
func (workqueueMetricsProvider) NewDepthMetric(name string) workqueuemetrics.GaugeMetric {
return depth.WithLabelValues(name)
}
func (workqueueMetricsProvider) NewAddsMetric(name string) workqueuemetrics.CounterMetric {
return adds.WithLabelValues(name)
}
func (workqueueMetricsProvider) NewLatencyMetric(name string) workqueuemetrics.SummaryMetric {
return latency.WithLabelValues(name)
}
func (workqueueMetricsProvider) NewWorkDurationMetric(name string) workqueuemetrics.SummaryMetric {
return workDuration.WithLabelValues(name)
}
func (workqueueMetricsProvider) NewRetriesMetric(name string) workqueuemetrics.CounterMetric {
return retries.WithLabelValues(name)
}
func (workqueueMetricsProvider) NewLongestRunningProcessorMicrosecondsMetric(name string) workqueuemetrics.SettableGaugeMetric {
return longestRunning.WithLabelValues(name)
}
func (workqueueMetricsProvider) NewUnfinishedWorkSecondsMetric(name string) workqueuemetrics.SettableGaugeMetric {
return unfinishedWork.WithLabelValues(name)
}