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

Create the config and namespace filterer #457

Merged
merged 19 commits into from
Jun 8, 2022

Conversation

marcsanmi
Copy link
Contributor

@marcsanmi marcsanmi commented May 24, 2022

Closes https://github.com/newrelic/newrelic-coreint/issues/324.

Filtering namespaces basically works this way:

  • Everything is scraped by default.
  • We can include namespaces by specific labels using namespaceSelector.matchLabels.
  • We can include or exclude namespaces using more complex expressions using namespaceSelector.matchExpressions (You can check as well https://pkg.go.dev/k8s.io/apimachinery/pkg/labels#Parse)

For more in depth details about the final solution, take a look at this internal doc.

@marcsanmi marcsanmi force-pushed the msanmiquel/add-config-namespace-filterer branch 2 times, most recently from 5dbcaa2 to ac1c7bb Compare May 31, 2022 05:53
@marcsanmi marcsanmi force-pushed the msanmiquel/add-config-namespace-filterer branch from ac1c7bb to 2f03281 Compare May 31, 2022 05:55
@marcsanmi marcsanmi marked this pull request as ready for review May 31, 2022 06:33
@marcsanmi marcsanmi requested a review from a team May 31, 2022 06:34
@marcsanmi marcsanmi changed the title Create config flag and namespace filterer Create the config and namespace filterer May 31, 2022
Copy link
Contributor

@sigilioso sigilioso left a comment

Choose a reason for hiding this comment

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

Great job so far! I left some comments, mostly nits.

internal/discovery/namespace_filter_test.go Outdated Show resolved Hide resolved
internal/discovery/namespace_filter.go Show resolved Hide resolved
internal/discovery/namespace_filter.go Outdated Show resolved Hide resolved
internal/discovery/namespace_filter.go Show resolved Hide resolved
@kang-makes kang-makes requested review from a team and sigilioso June 1, 2022 10:10
Copy link
Contributor

@sigilioso sigilioso left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for addressing the comments 👍

@marcsanmi marcsanmi requested a review from a team June 2, 2022 06:47
@sigilioso sigilioso self-requested a review June 2, 2022 15:21
Copy link
Contributor

@gsanchezgavier gsanchezgavier left a comment

Choose a reason for hiding this comment

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

looks really good, i lefts some questions and comments

internal/config/config.go Outdated Show resolved Hide resolved
internal/config/config.go Outdated Show resolved Hide resolved
internal/discovery/namespace_filter.go Show resolved Hide resolved
internal/discovery/namespace_filter.go Outdated Show resolved Hide resolved
internal/discovery/namespace_filter.go Outdated Show resolved Hide resolved
internal/discovery/namespace_filter_test.go Show resolved Hide resolved
internal/discovery/namespace_filter.go Outdated Show resolved Hide resolved
Comment on lines 17 to 20
// NamespaceFilterer provides an interface to filter namespaces.
type NamespaceFilterer interface {
IsAllowed(namespace string) bool
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if this interface is too specific. What would be the advantage of having a filter specific to namespaces, as opposed to a filter that takes in fetch.RawMetrics and returns a bool? NamespaceFilter could be a particular implementation of this, looking for metrics["namespace"]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right, I updated the interface definition and implementation here e57ba69.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After talking with @alvarocabanas and @sigilioso, we decided to move back again to the initial definition. Implementing the solution suggested above would imply some refactor in order to avoid cyclic dependencies between definition and discovery packages and to make the code maintainable.

Done in 95f8b9d.

We can talk about this when you come back 🙂

internal/discovery/namespace_filter.go Show resolved Hide resolved
internal/discovery/namespace_filter.go Outdated Show resolved Hide resolved
internal/discovery/namespace_filter.go Outdated Show resolved Hide resolved
internal/discovery/namespace_filter.go Outdated Show resolved Hide resolved
internal/storer/storer.go Outdated Show resolved Hide resolved
Copy link
Contributor

@alvarocabanas alvarocabanas left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@gsanchezgavier gsanchezgavier left a comment

Choose a reason for hiding this comment

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

LGTM

charts/newrelic-infrastructure/values.yaml Show resolved Hide resolved
@marcsanmi marcsanmi merged commit a42ee4f into main Jun 8, 2022
@marcsanmi marcsanmi deleted the msanmiquel/add-config-namespace-filterer branch June 8, 2022 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants