mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-06 18:54:06 +00:00
added sync and register func
This commit is contained in:
parent
89c375bc74
commit
daf7edb8f4
@ -17,13 +17,14 @@ limitations under the License.
|
|||||||
package controllers
|
package controllers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"sync"
|
||||||
|
|
||||||
k8smetrics "k8s.io/component-base/metrics"
|
k8smetrics "k8s.io/component-base/metrics"
|
||||||
"k8s.io/component-base/metrics/legacyregistry"
|
"k8s.io/component-base/metrics/legacyregistry"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// Metrics provides access to all controllerreadiness metrics.
|
once sync.Once
|
||||||
Metrics = newControllerMetrics()
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// ControllerMetrics includes all the metrics of the proxy server.
|
// ControllerMetrics includes all the metrics of the proxy server.
|
||||||
@ -32,7 +33,7 @@ type ControllerMetrics struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// newControllerMetrics create a new ControllerMetrics, configured with default metric names.
|
// newControllerMetrics create a new ControllerMetrics, configured with default metric names.
|
||||||
func newControllerMetrics() *ControllerMetrics {
|
func NewControllerMetrics() *ControllerMetrics {
|
||||||
controllerInstanceCount := k8smetrics.NewGaugeVec(
|
controllerInstanceCount := k8smetrics.NewGaugeVec(
|
||||||
&k8smetrics.GaugeOpts{
|
&k8smetrics.GaugeOpts{
|
||||||
Name: "managed_controller_instances",
|
Name: "managed_controller_instances",
|
||||||
@ -41,10 +42,18 @@ func newControllerMetrics() *ControllerMetrics {
|
|||||||
},
|
},
|
||||||
[]string{"name", "manager"},
|
[]string{"name", "manager"},
|
||||||
)
|
)
|
||||||
legacyregistry.MustRegister(controllerInstanceCount)
|
//legacyregistry.MustRegister(controllerInstanceCount)
|
||||||
return &ControllerMetrics{
|
controllerMetrics := &ControllerMetrics{
|
||||||
controllerInstanceCount: controllerInstanceCount,
|
controllerInstanceCount: controllerInstanceCount,
|
||||||
}
|
}
|
||||||
|
once.Do(func() {
|
||||||
|
controllerMetrics.Register()
|
||||||
|
})
|
||||||
|
return controllerMetrics
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *ControllerMetrics) Register() {
|
||||||
|
legacyregistry.MustRegister(a.controllerInstanceCount)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ControllerStarted sets the controllerInstanceCount to 1.
|
// ControllerStarted sets the controllerInstanceCount to 1.
|
||||||
|
Loading…
Reference in New Issue
Block a user