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

chore: refactor metrics namespace check #5489

Merged
merged 2 commits into from
Nov 28, 2022

Conversation

eddycharly
Copy link
Member

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.

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
@codecov
Copy link

codecov bot commented Nov 28, 2022

Codecov Report

Merging #5489 (42dbd78) into main (ff93288) will decrease coverage by 0.02%.
The diff coverage is 0.00%.

@@            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              
Impacted Files Coverage Δ
pkg/config/metricsconfig.go 0.00% <0.00%> (ø)

📣 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 == "-" {
Copy link
Member

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?

Copy link
Member Author

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 {
Copy link
Member Author

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.

Copy link
Member

Choose a reason for hiding this comment

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

ok.

@eddycharly eddycharly merged commit f9f01fc into kyverno:main Nov 28, 2022
@eddycharly eddycharly deleted the refactor-metrics-check branch November 28, 2022 15:53
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.

None yet

2 participants