Merge pull request #3220 from xyz-li/master

add metrics
This commit is contained in:
KubeSphere CI Bot
2021-01-15 10:16:37 +08:00
committed by GitHub
8 changed files with 182 additions and 2 deletions

View 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)
}

View File

@@ -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