24
pkg/controller/workspace/metrics.go
Normal file
24
pkg/controller/workspace/metrics.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package workspace
|
||||
|
||||
import (
|
||||
compbasemetrics "k8s.io/component-base/metrics"
|
||||
"kubesphere.io/kubesphere/pkg/utils/metrics"
|
||||
)
|
||||
|
||||
var (
|
||||
workspaceOperation = compbasemetrics.NewCounterVec(
|
||||
&compbasemetrics.CounterOpts{
|
||||
Name: "ks_controller_manager_workspace_operation",
|
||||
Help: "Counter of ks controller manager workspace operation broken out for each operation, name",
|
||||
// This metric is used for verifying api call latencies SLO,
|
||||
// as well as tracking regressions in this aspects.
|
||||
// Thus we customize buckets significantly, to empower both usecases.
|
||||
StabilityLevel: compbasemetrics.ALPHA,
|
||||
},
|
||||
[]string{"operation", "name"},
|
||||
)
|
||||
)
|
||||
|
||||
func init() {
|
||||
metrics.MustRegister(workspaceOperation)
|
||||
}
|
||||
@@ -98,6 +98,7 @@ func (r *Reconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
|
||||
if err := r.Update(rootCtx, workspace); err != nil {
|
||||
return ctrl.Result{}, err
|
||||
}
|
||||
workspaceOperation.WithLabelValues("create", workspace.Name).Inc()
|
||||
}
|
||||
} else {
|
||||
// The object is being deleted
|
||||
@@ -111,6 +112,7 @@ func (r *Reconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
|
||||
logger.Error(err, "update workspace failed")
|
||||
return ctrl.Result{}, err
|
||||
}
|
||||
workspaceOperation.WithLabelValues("delete", workspace.Name).Inc()
|
||||
}
|
||||
// Our finalizer has finished, so the reconciler can do nothing.
|
||||
return ctrl.Result{}, nil
|
||||
|
||||
Reference in New Issue
Block a user