Skip to content
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

webhook: register metrics only with default stats reporter #3005

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

zhouhaibing089
Copy link
Contributor

This is a followup from knative/pkg#2931. RegisterMetrics may register unwanted metrics if the default stats reporter is not used.

/kind cleanup

None

This is a followup from [knative#2931][1]. RegisterMetrics may
register unwanted metrics if the default stats reporter is not used.

[1]: knative#2931
@knative-prow knative-prow bot added the kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. label Apr 2, 2024
@knative-prow knative-prow bot requested a review from Leo6Leo April 2, 2024 04:49
Copy link

knative-prow bot commented Apr 2, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: zhouhaibing089
Once this PR has been reviewed and has the lgtm label, please assign creydr for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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

@knative-prow knative-prow bot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Apr 2, 2024
Copy link

knative-prow bot commented Apr 2, 2024

Hi @zhouhaibing089. Thanks for your PR.

I'm waiting for a knative member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Copy link

codecov bot commented Apr 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.77%. Comparing base (03bf3de) to head (220f45b).
Report is 56 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3005      +/-   ##
==========================================
+ Coverage   78.75%   78.77%   +0.01%     
==========================================
  Files         188      188              
  Lines       11107     8870    -2237     
==========================================
- Hits         8747     6987    -1760     
+ Misses       2094     1617     -477     
  Partials      266      266              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@dprotaso
Copy link
Member

dprotaso commented Apr 3, 2024

/ok-to-test

@knative-prow knative-prow bot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Apr 3, 2024
@@ -147,6 +152,8 @@ func New(
logger := logging.FromContext(ctx)

if opts.StatsReporter == nil {
// Register webhook metrics
metricsOnce.Do(func() { RegisterMetrics(opts.StatsReporterOptions...) })
Copy link
Member

Choose a reason for hiding this comment

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

Before RegisterMetrics would always be called. Now it's only being invokved when the opts.StatsReporter isnt' set.

This seems like a breaking change

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree with your assessment. It might break users who specify StatsReporter yet still rely on RegisterMetrics to register views properly.

However I consider this as an unpleasant situation when users want to use a different StatsReporter but register the same view with slightly different tags.

To be fair, this is not something that I need anymore since the default StatsReporter can be customized already.

As it is today, webhook.NewStatsReporter() and webhook.RegisterMetrics() seems to be independent interfaces while they actually share the same data structure (tracks the same metrics tags, and relies on the same opts.StatsReporterOptions to initialize).

Copy link
Member

Choose a reason for hiding this comment

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

@skonto do you have any opinions?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think a migration path would be to have a flag disableDefaultMetrics with default being false.

Copy link
Contributor

github-actions bot commented Jul 3, 2024

This Pull Request is stale because it has been open for 90 days with
no activity. It will automatically close after 30 more days of
inactivity. Reopen with /reopen. Mark as fresh by adding the
comment /remove-lifecycle stale.

@github-actions github-actions bot added lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Jul 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants