-
Notifications
You must be signed in to change notification settings - Fork 776
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
chore: refactor metrics namespace check #5489
Conversation
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
Codecov Report
@@ Coverage Diff @@
## main #5489 +/- ##
==========================================
- Coverage 36.54% 36.52% -0.03%
==========================================
Files 171 171
Lines 19095 19107 +12
==========================================
Hits 6979 6979
- Misses 11324 11336 +12
Partials 792 792
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
// CheckNamespace returns `true` if the namespace has to be considered | ||
func (mcd *metricsConfig) CheckNamespace(namespace string) bool { | ||
// TODO(eddycharly): check we actually need `"-"` | ||
if namespace == "" || namespace == "-" { |
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.
What does -
mean? The empty or default namespace?
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.
Looks like it's empty.
@@ -23,24 +21,13 @@ func registerPolicyExecutionDurationMetric( | |||
ruleType metrics.RuleType, | |||
ruleExecutionCause metrics.RuleExecutionCause, | |||
ruleExecutionLatency float64, | |||
) error { | |||
) { | |||
if policyType == metrics.Cluster { |
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.
cc @realshuting we seem to use it for clustered resources.
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.
ok.
Signed-off-by: Charles-Edouard Brétéché charles.edouard@nirmata.com
Explanation
This PR refactors metrics namespace check.
Factorises out the code and removes unnecessary errors when returning always
nil
.