k8s.io/kubernetes@v1.31.0-alpha.0.0.20240520171757-56147500dadc/pkg/registry/core/service/portallocator/controller/metrics.go (about) 1 /* 2 Copyright 2023 The Kubernetes Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package controller 18 19 import ( 20 "sync" 21 22 "k8s.io/component-base/metrics" 23 "k8s.io/component-base/metrics/legacyregistry" 24 ) 25 26 const ( 27 namespace = "apiserver" 28 subsystem = "nodeport_repair" 29 ) 30 31 var ( 32 // nodePortRepairPortErrors indicates the number of errors found by the repair loop 33 // divided by the type of error: 34 // leak, repair, full, outOfRange, duplicate, unknown 35 nodePortRepairPortErrors = metrics.NewCounterVec( 36 &metrics.CounterOpts{ 37 Namespace: namespace, 38 Subsystem: subsystem, 39 Name: "port_errors_total", 40 Help: "Number of errors detected on ports by the repair loop broken down by type of error: leak, repair, full, outOfRange, duplicate, unknown", 41 StabilityLevel: metrics.ALPHA, 42 }, 43 []string{"type"}, 44 ) 45 // nodePortRepairReconcileErrors indicates the number of times the repair loop has failed to repair 46 // the errors it detected. 47 nodePortRepairReconcileErrors = metrics.NewCounter( 48 &metrics.CounterOpts{ 49 Namespace: namespace, 50 Subsystem: subsystem, 51 Name: "reconcile_errors_total", 52 Help: "Number of reconciliation failures on the nodeport repair reconcile loop", 53 StabilityLevel: metrics.ALPHA, 54 }, 55 ) 56 ) 57 58 var registerMetricsOnce sync.Once 59 60 func registerMetrics() { 61 registerMetricsOnce.Do(func() { 62 legacyregistry.MustRegister(nodePortRepairPortErrors) 63 legacyregistry.MustRegister(nodePortRepairReconcileErrors) 64 }) 65 }