-
Notifications
You must be signed in to change notification settings - Fork 331
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: add options to disable resource_namespace tag in metrics #2931
webhook: add options to disable resource_namespace tag in metrics #2931
Conversation
Welcome @zhouhaibing089! It looks like this is your first PR to knative/pkg 🎉 |
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 Once the patch is verified, the new status will be reflected by the 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. |
/hold we have a release in the next week Will revisit this after |
/ok-to-test |
/retest (The failed tests reported seem to be fine locally) |
They're consistent in CI - try using a docker container with ubuntu? |
b85215c
to
57ecce6
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2931 +/- ##
==========================================
+ Coverage 78.68% 78.75% +0.07%
==========================================
Files 188 188
Lines 11051 11107 +56
==========================================
+ Hits 8695 8747 +52
- Misses 2092 2094 +2
- Partials 264 266 +2 ☔ View full report in Codecov by Sentry. |
Kindly ping, may I get some attention here? |
Hi @zhouhaibing089 sorry for the delay, just to clarify here we have two changes: I think it would be more flexible if we can exclude an arbitrary tag key instead of having if statements like:
We could use:
wdyth? |
707ab02
to
bb36b9d
Compare
Thanks. I completely agree (PR updated with your suggestion). |
d3a896c
to
cb50ed6
Compare
/retest |
Overall looks great thanks for the changes - some minor stuff |
b7ac4a9
to
e153848
Compare
To add some context, historically, `resource_name` was removed from this tag list due to its high potential of causing high metrics cardinality. See [knative#1464][1] for more information. While that's great, but it might not be sufficient for large scale use cases where namespaces can be super dynamic (with generateName, too) or grows fase enough. There is an issue report from [tektoncd/pipeline#3171][2] which talks about this. This proposal makes it possible to disable `resource_namespace` tag via an option function. The default behavior is not changed, so no user impact if any of existing users rely on this tag. There is no API contract change either due to the beauty of variadic functions. Now downstream projects can consume this by override `StatsReporter` in webhook context options with their own preference. As a caveat here, if downstream project does choose to override `StatsReporter`, the default `ReportMetrics` function shouldn't be called by default as they may now have a different set of tag keys to report. As such, this function is only called if the default `StatsReporter` is used. [1]: knative#1464 [2]: tektoncd/pipeline#3171
e153848
to
927e9ff
Compare
/hold cancel |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the changes - just some minor nil
checks left
There are two ways to customize StatsReporter: 1. Use a whole new StatsReporter implementation. 1. Or pass Option funcs to customize the default StatsReporter. Option 1 is less practical at this time due to the metrics registration conflict. `webhook.RegisterMetrics()` is called regardless which StatsReporter implementation is used (which is a problem by itself). The second option is more practical since it works well without dealing with metrics conflicts. The `webhook.Option` in particular allows people to discard certain metrics tags.
927e9ff
to
46a2e06
Compare
/lgtm thanks @zhouhaibing089 🎉 |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: dprotaso, zhouhaibing089 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 |
This is a followup from [knative#2931][1]. RegisterMetrics may register unwanted metrics if the default stats reporter is not used. [1]: knative#2931
To add some context, historically,
resource_name
was removed from this tag list due to its high potential of causing high metrics cardinality. See knative/pkg#1464 for more information.While that's great, but it might not be sufficient for large scale use cases where namespaces can be super dynamic (with generateName, too) or grows fase enough. There is an issue report from
tektoncd/pipeline#3171 which talks about this.
This proposal makes it possible to disable
resource_namespace
tag via an option function. The default behavior is not changed, so no user impact if any of existing users rely on this tag. There is no API contract change either due to the beauty of variadic functions.Now downstream projects can consume this by override
StatsReporter
in webhook context options with their own preference. As a caveat here, if downstream project does choose to overrideStatsReporter
, the defaultReportMetrics
function shouldn't be called by default as they may now have a different set of tag keys to report. As such, this function is only called if the defaultStatsReporter
is used.