mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-15 06:43:54 +00:00
updated with fixes based on comments by dgrisonnet
This commit is contained in:
parent
5947ee3653
commit
89c375bc74
@ -35,11 +35,11 @@ type ControllerMetrics struct {
|
|||||||
func newControllerMetrics() *ControllerMetrics {
|
func newControllerMetrics() *ControllerMetrics {
|
||||||
controllerInstanceCount := k8smetrics.NewGaugeVec(
|
controllerInstanceCount := k8smetrics.NewGaugeVec(
|
||||||
&k8smetrics.GaugeOpts{
|
&k8smetrics.GaugeOpts{
|
||||||
Name: "managed_controller_instance_count",
|
Name: "managed_controller_instances",
|
||||||
Help: "Instances of individual controllers currently running",
|
Help: "Instances of individual controllers currently running",
|
||||||
StabilityLevel: k8smetrics.ALPHA,
|
StabilityLevel: k8smetrics.ALPHA,
|
||||||
},
|
},
|
||||||
[]string{"controller_name", "controller_manager"},
|
[]string{"name", "manager"},
|
||||||
)
|
)
|
||||||
legacyregistry.MustRegister(controllerInstanceCount)
|
legacyregistry.MustRegister(controllerInstanceCount)
|
||||||
return &ControllerMetrics{
|
return &ControllerMetrics{
|
||||||
@ -50,11 +50,11 @@ func newControllerMetrics() *ControllerMetrics {
|
|||||||
// ControllerStarted sets the controllerInstanceCount to 1.
|
// ControllerStarted sets the controllerInstanceCount to 1.
|
||||||
// These values use set instead of inc/dec to avoid accidentally double counting
|
// These values use set instead of inc/dec to avoid accidentally double counting
|
||||||
// a controller that starts but fails to properly signal when it crashes.
|
// a controller that starts but fails to properly signal when it crashes.
|
||||||
func (a *ControllerMetrics) ControllerStarted(controllerName string, controllerManager string) {
|
func (a *ControllerMetrics) ControllerStarted(name string, manager string) {
|
||||||
a.controllerInstanceCount.With(k8smetrics.Labels{"controller_name": controllerName, "controller_manager": controllerManager}).Set(float64(1))
|
a.controllerInstanceCount.With(k8smetrics.Labels{"name": name, "manager": manager}).Set(float64(1))
|
||||||
}
|
}
|
||||||
|
|
||||||
// ControllerStopped sets the controllerInstanceCount to 0.
|
// ControllerStopped sets the controllerInstanceCount to 0.
|
||||||
func (a *ControllerMetrics) ControllerStopped(controllerName string, controllerManager string) {
|
func (a *ControllerMetrics) ControllerStopped(name string, manager string) {
|
||||||
a.controllerInstanceCount.With(k8smetrics.Labels{"controller_name": controllerName, "controller_manager": controllerManager}).Set(float64(0))
|
a.controllerInstanceCount.With(k8smetrics.Labels{"name": name, "manager": manager}).Set(float64(0))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user