Skip to content

Commit

Permalink
Merge pull request #189 from jmencak/4.7-metrics-fix
Browse files Browse the repository at this point in the history
Bug 1907936: Switch to nto_profile_calculated_total.
  • Loading branch information
openshift-merge-robot committed Dec 15, 2020
2 parents 247cd5b + 4a5a8cf commit 572d4d9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
16 changes: 8 additions & 8 deletions pkg/metrics/metrics.go
Expand Up @@ -4,10 +4,10 @@ import "github.com/prometheus/client_golang/prometheus"

// When adding metric names, see https://prometheus.io/docs/practices/naming/#metric-names
const (
podLabelsUsedQuery = "nto_pod_labels_used_info"
profileSetQuery = "nto_profile_set_total"
buildInfoQuery = "nto_build_info"
degradedInfoQuery = "nto_degraded_info"
podLabelsUsedQuery = "nto_pod_labels_used_info"
profileCalculatedQuery = "nto_profile_calculated_total"
buildInfoQuery = "nto_build_info"
degradedInfoQuery = "nto_degraded_info"

// MetricsPort is the IP port supplied to the HTTP server used for Prometheus,
// and matches what is specified in the corresponding Service and ServiceMonitor.
Expand All @@ -22,10 +22,10 @@ var (
Help: "Is the Pod label functionality turned on (1) or off (0)?",
},
)
profileSet = prometheus.NewCounterVec(
profileCalculated = prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: profileSetQuery,
Help: "The number of times a Tuned profile was set for a given node.",
Name: profileCalculatedQuery,
Help: "The number of times a Tuned profile was calculated for a given node.",
},
[]string{"node", "profile"},
)
Expand All @@ -47,7 +47,7 @@ var (
func init() {
registry.MustRegister(
podLabelsUsed,
profileSet,
profileCalculated,
buildInfo,
degradedState,
)
Expand Down
8 changes: 4 additions & 4 deletions pkg/metrics/server.go
Expand Up @@ -58,10 +58,10 @@ func PodLabelsUsed(enable bool) {
podLabelsUsed.Set(0)
}

// ProfileSet keeps track of the number of times a given Tuned profile
// resource was set for node 'nodeName'.
func ProfileSet(nodeName, profileName string) {
profileSet.With(map[string]string{"node": nodeName, "profile": profileName}).Inc()
// ProfileCalculated keeps track of the number of times a given Tuned profile
// resource was calculated for node 'nodeName'.
func ProfileCalculated(nodeName, profileName string) {
profileCalculated.With(map[string]string{"node": nodeName, "profile": profileName}).Inc()
}

// RegisterVersion exposes the Operator build version.
Expand Down
3 changes: 1 addition & 2 deletions pkg/operator/controller.go
Expand Up @@ -512,6 +512,7 @@ func (c *Controller) syncProfile(tuned *tunedv1.Tuned, nodeName string) error {
if err != nil {
return err
}
metrics.ProfileCalculated(profileMf.Name, tunedProfileName)

profile, err := c.listers.TunedProfiles.Get(profileMf.Name)
if err != nil {
Expand All @@ -534,7 +535,6 @@ func (c *Controller) syncProfile(tuned *tunedv1.Tuned, nodeName string) error {
}
// Profile created successfully
klog.Infof("created profile %s [%s]", profileMf.Name, tunedProfileName)
metrics.ProfileSet(profileMf.Name, tunedProfileName)
return nil
}

Expand Down Expand Up @@ -565,7 +565,6 @@ func (c *Controller) syncProfile(tuned *tunedv1.Tuned, nodeName string) error {
return fmt.Errorf("failed to update Profile %s: %v", profile.Name, err)
}
klog.Infof("updated profile %s [%s]", profile.Name, tunedProfileName)
metrics.ProfileSet(nodeName, tunedProfileName)

return nil
}
Expand Down

0 comments on commit 572d4d9

Please sign in to comment.