Skip to content

Commit

Permalink
remove the dependency on the component-base/metrics package.
Browse files Browse the repository at this point in the history
Signed-off-by: chaosi-zju <chaosi@zju.edu.cn>
  • Loading branch information
chaosi-zju committed Dec 12, 2024
1 parent 471d850 commit 7911b9f
Show file tree
Hide file tree
Showing 59 changed files with 29 additions and 9,319 deletions.
58 changes: 27 additions & 31 deletions pkg/controllers/federatedhpa/monitor/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ package monitor
import (
"sync"

"k8s.io/component-base/metrics"
"k8s.io/component-base/metrics/legacyregistry"
"github.com/prometheus/client_golang/prometheus"
ctrlmetrics "sigs.k8s.io/controller-runtime/pkg/metrics"
)

const (
Expand All @@ -30,39 +30,35 @@ const (
)

var (
reconciliationsTotal = metrics.NewCounterVec(
&metrics.CounterOpts{
Subsystem: hpaControllerSubsystem,
Name: "reconciliations_total",
Help: "Number of reconciliations of HPA controller. The label 'action' should be either 'scale_down', 'scale_up', or 'none'. Also, the label 'error' should be either 'spec', 'internal', or 'none'. Note that if both spec and internal errors happen during a reconciliation, the first one to occur is reported in `error` label.",
StabilityLevel: metrics.ALPHA,
reconciliationsTotal = prometheus.NewCounterVec(
prometheus.CounterOpts{
Subsystem: hpaControllerSubsystem,
Name: "reconciliations_total",
Help: "Number of reconciliations of HPA controller. The label 'action' should be either 'scale_down', 'scale_up', or 'none'. Also, the label 'error' should be either 'spec', 'internal', or 'none'. Note that if both spec and internal errors happen during a reconciliation, the first one to occur is reported in `error` label.",
}, []string{"action", "error"})

reconciliationsDuration = metrics.NewHistogramVec(
&metrics.HistogramOpts{
Subsystem: hpaControllerSubsystem,
Name: "reconciliation_duration_seconds",
Help: "The time(seconds) that the HPA controller takes to reconcile once. The label 'action' should be either 'scale_down', 'scale_up', or 'none'. Also, the label 'error' should be either 'spec', 'internal', or 'none'. Note that if both spec and internal errors happen during a reconciliation, the first one to occur is reported in `error` label.",
Buckets: metrics.ExponentialBuckets(0.001, 2, 15),
StabilityLevel: metrics.ALPHA,
reconciliationsDuration = prometheus.NewHistogramVec(
prometheus.HistogramOpts{
Subsystem: hpaControllerSubsystem,
Name: "reconciliation_duration_seconds",
Help: "The time(seconds) that the HPA controller takes to reconcile once. The label 'action' should be either 'scale_down', 'scale_up', or 'none'. Also, the label 'error' should be either 'spec', 'internal', or 'none'. Note that if both spec and internal errors happen during a reconciliation, the first one to occur is reported in `error` label.",
Buckets: prometheus.ExponentialBuckets(0.001, 2, 15),
}, []string{"action", "error"})
metricComputationTotal = metrics.NewCounterVec(
&metrics.CounterOpts{
Subsystem: hpaControllerSubsystem,
Name: "metric_computation_total",
Help: "Number of metric computations. The label 'action' should be either 'scale_down', 'scale_up', or 'none'. Also, the label 'error' should be either 'spec', 'internal', or 'none'. The label 'metric_type' corresponds to HPA.spec.metrics[*].type",
StabilityLevel: metrics.ALPHA,
metricComputationTotal = prometheus.NewCounterVec(
prometheus.CounterOpts{
Subsystem: hpaControllerSubsystem,
Name: "metric_computation_total",
Help: "Number of metric computations. The label 'action' should be either 'scale_down', 'scale_up', or 'none'. Also, the label 'error' should be either 'spec', 'internal', or 'none'. The label 'metric_type' corresponds to HPA.spec.metrics[*].type",
}, []string{"action", "error", "metric_type"})
metricComputationDuration = metrics.NewHistogramVec(
&metrics.HistogramOpts{
Subsystem: hpaControllerSubsystem,
Name: "metric_computation_duration_seconds",
Help: "The time(seconds) that the HPA controller takes to calculate one metric. The label 'action' should be either 'scale_down', 'scale_up', or 'none'. The label 'error' should be either 'spec', 'internal', or 'none'. The label 'metric_type' corresponds to HPA.spec.metrics[*].type",
Buckets: metrics.ExponentialBuckets(0.001, 2, 15),
StabilityLevel: metrics.ALPHA,
metricComputationDuration = prometheus.NewHistogramVec(
prometheus.HistogramOpts{
Subsystem: hpaControllerSubsystem,
Name: "metric_computation_duration_seconds",
Help: "The time(seconds) that the HPA controller takes to calculate one metric. The label 'action' should be either 'scale_down', 'scale_up', or 'none'. The label 'error' should be either 'spec', 'internal', or 'none'. The label 'metric_type' corresponds to HPA.spec.metrics[*].type",
Buckets: prometheus.ExponentialBuckets(0.001, 2, 15),
}, []string{"action", "error", "metric_type"})

metricsList = []metrics.Registerable{
metricsList = []prometheus.Collector{
reconciliationsTotal,
reconciliationsDuration,
metricComputationTotal,
Expand All @@ -81,8 +77,8 @@ func Register() {
}

// RegisterMetrics registers a list of metrics.
func registerMetrics(extraMetrics ...metrics.Registerable) {
func registerMetrics(extraMetrics ...prometheus.Collector) {
for _, metric := range extraMetrics {
legacyregistry.MustRegister(metric)
ctrlmetrics.Registry.MustRegister(metric)
}
}
5 changes: 2 additions & 3 deletions pkg/resourceinterpreter/customized/webhook/customized.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import (
webhookutil "k8s.io/apiserver/pkg/util/webhook"
corev1 "k8s.io/client-go/listers/core/v1"
"k8s.io/klog/v2"
"k8s.io/kube-aggregator/pkg/apiserver"
utiltrace "k8s.io/utils/trace"

configv1alpha1 "github.com/karmada-io/karmada/pkg/apis/config/v1alpha1"
Expand All @@ -51,7 +50,7 @@ type CustomizedInterpreter struct {
}

// NewCustomizedInterpreter return a new CustomizedInterpreter.
func NewCustomizedInterpreter(informer genericmanager.SingleClusterInformerManager, serviceLister corev1.ServiceLister) (*CustomizedInterpreter, error) {
func NewCustomizedInterpreter(informer genericmanager.SingleClusterInformerManager, _ corev1.ServiceLister) (*CustomizedInterpreter, error) {
cm, err := webhookutil.NewClientManager(
[]schema.GroupVersion{
{
Expand All @@ -70,7 +69,7 @@ func NewCustomizedInterpreter(informer genericmanager.SingleClusterInformerManag
}

cm.SetAuthenticationInfoResolver(authInfoResolver)
cm.SetServiceResolver(apiserver.NewClusterIPServiceResolver(serviceLister))
cm.SetServiceResolver(webhookutil.NewDefaultServiceResolver())

return &CustomizedInterpreter{
hookManager: configmanager.NewExploreConfigManager(informer),
Expand Down
70 changes: 0 additions & 70 deletions vendor/k8s.io/apimachinery/pkg/api/meta/table/table.go

This file was deleted.

Loading

0 comments on commit 7911b9f

Please sign in to comment.