Skip to content

Add hub_template_active_watches metric #61

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

dhaiducek
Copy link
Member

Adds a Gauge Vector that records the number of active watches for each root policy.

Addresses:

// Clean up hub template watch metric
log.V(3).Info("Deleting hub template watch metric")

metricDeleted := hubTemplateActiveWatchesMetric.Delete(prometheus.Labels{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think this would be better in cleanUpPolicy?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I put it here so that it would be more visible alongside the other metric setting. I figured that way if we wanted to update it in the future, it'd all be in a single file and a single function.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...but using defer covers the cleanup case also, right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup since we would just want it to be 0 when there are no more watches and not delete the metric. If we had a watch count per policy, then we would delete the metric when the policy gets deleted.

hubTempWatches := r.DynamicWatcher.GetWatchCount()
log.V(3).Info("Setting hub template watch metric", "value", hubTempWatches)

gaugeMetric, err := hubTemplateActiveWatchesMetric.GetMetricWith(prometheus.Labels{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GetWatchCount is for all watches and not just the watches for that particular policy.

I do like your idea of being able to distinguish which policy has a lot of watches. Perhaps we could add a method to the dynamic watcher library to accept an ObjectIdentifier to get the watch count?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The latest changes I have locally use Gauge instead of GaugeVec. I think I need to focus time on my other issues at this point, especially since the cleanup of GaugeVec becomes a little sticky. 🙂

@mprahl
Copy link
Member

mprahl commented Oct 31, 2022

Could you please fix the commit message for Fix log message to use Sprintf since it's not using Sprintf anymore?

@dhaiducek dhaiducek force-pushed the watch-count branch 2 times, most recently from 2284420 to c746829 Compare October 31, 2022 18:31
dhaiducek and others added 3 commits October 31, 2022 14:32
Co-authored-by: Matt Prahl <[email protected]>
Signed-off-by: Dale Haiducek <[email protected]>
Signed-off-by: Dale Haiducek <[email protected]>
Gauge that records the current number of active watches.

ref: stolostron/backlog#25866
Signed-off-by: Dale Haiducek <[email protected]>
@openshift-ci
Copy link

openshift-ci bot commented Oct 31, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dhaiducek, mprahl

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants