Skip to content

Commit

Permalink
Rename field
Browse files Browse the repository at this point in the history
  • Loading branch information
luksa committed Apr 25, 2023
1 parent 4f64da2 commit ffe6d17
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions pkg/controller/servicemesh/memberroll/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ func (r *MemberRollReconciler) Reconcile(request reconcile.Request) (reconcile.R
if err != nil {
if errors.IsNotFound(err) {
// Request object not found, could have been deleted after reconcile request.
internalmetrics.ResetSMCPMember()
internalmetrics.ResetMeshMembers()
return reconcile.Result{}, nil
}
// Error reading the object
Expand Down Expand Up @@ -262,10 +262,10 @@ func (r *MemberRollReconciler) reconcileObject(ctx context.Context, roll *maistr
switch len(meshList.Items) {
case 0:
mesh = nil
internalmetrics.ResetSMCPMember()
internalmetrics.ResetMeshMembers()
case 1:
mesh = &meshList.Items[0]
internalmetrics.ResetSMCPMember()
internalmetrics.ResetMeshMembers()
default: // more than 1 SMCP found
reason := maistrav1.ConditionReasonMultipleSMCP
message := "Multiple ServiceMeshControlPlane resources exist in the namespace"
Expand Down Expand Up @@ -426,7 +426,7 @@ func (r *MemberRollReconciler) reconcileObject(ctx context.Context, roll *maistr
if err != nil {
return reconcile.Result{}, err
}
internalmetrics.GetSMCPMember(mesh.GetNamespace(), mesh.Spec.Version, meshMode).Set(float64(len(roll.Status.ConfiguredMembers)))
internalmetrics.GetMeshMembers(mesh.GetNamespace(), mesh.Spec.Version, meshMode).Set(float64(len(roll.Status.ConfiguredMembers)))
}
return reconcile.Result{}, nil
}
Expand Down
14 changes: 7 additions & 7 deletions pkg/internalmetrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ const (

// MetricsType defines all of istio-operator's metrics.
type MetricsType struct {
SMCPMember *prometheus.GaugeVec
MeshMembers *prometheus.GaugeVec
}

// Metrics contains all of istio-operator's own internal metrics.
// These metrics can be accessed directly to update their values, or
// you can use available utility functions defined below.
var Metrics = MetricsType{
SMCPMember: prometheus.NewGaugeVec(
MeshMembers: prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "servicemesh_members",
Help: "Number of SMCP members per namespace, mesh mode and version.",
Expand All @@ -38,18 +38,18 @@ var Metrics = MetricsType{
// RegisterMetrics must be called at startup to prepare the Prometheus scrape endpoint.
func RegisterMetrics() {
metrics.Registry.MustRegister(
Metrics.SMCPMember,
Metrics.MeshMembers,
)
}

func GetSMCPMember(smcpNamespace, smcpVersion, smcpMode string) prometheus.Gauge {
return Metrics.SMCPMember.With(prometheus.Labels{
func GetMeshMembers(smcpNamespace, smcpVersion, smcpMode string) prometheus.Gauge {
return Metrics.MeshMembers.With(prometheus.Labels{
labelSMCPNamespace: smcpNamespace,
labelSMCPVersion: smcpVersion,
labelSMCPMode: smcpMode,
})
}

func ResetSMCPMember() {
Metrics.SMCPMember.Reset()
func ResetMeshMembers() {
Metrics.MeshMembers.Reset()
}

0 comments on commit ffe6d17

Please sign in to comment.