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

[receiver/kafkareceiver] add topic_regex configuration option #36909

Conversation

wojtekzyla
Copy link
Contributor

Description

By adding topic_regex option in configuration we can allow kafka topics subscription based on name pattern instead of literal name string. Existing topic option still remains, so users can choose which solution they prefer.

Testing

Unit tests and manual testing

Documentation

Added new record in README.md

@wojtekzyla wojtekzyla requested review from MovieStoreGuy and a team as code owners December 20, 2024 11:17
Copy link

linux-foundation-easycla bot commented Dec 20, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

@@ -96,5 +99,8 @@ var _ component.Config = (*Config)(nil)

// Validate checks the receiver configuration is valid
func (cfg *Config) Validate() error {
if len(cfg.Topic) > 0 && len(cfg.TopicRegex) > 0 {
Copy link
Member

@JaredTan95 JaredTan95 Jan 7, 2025

Choose a reason for hiding this comment

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

I wonder if it is more appropriate to use the logic of priority: If TopicRegex is not empty, then ignore Topic

Copy link
Contributor Author

@wojtekzyla wojtekzyla Jan 7, 2025

Choose a reason for hiding this comment

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

This might be right I changed that. I removed this validation rule. Remaining code works in such a way that when TopicRegex is configured we start looking for new topics which match the regex and if they are detected we overwrite list of topics that we subscribe to: link

@wojtekzyla wojtekzyla force-pushed the feat/kafkareceiver-regex-topics branch 2 times, most recently from 4d7678d to ec5d0d9 Compare January 7, 2025 11:11
update changelog

when both TopicRegex and Topic are configured, ignore Topic

Update config_test.go

bring back empty Validate() in config.go

test literal topic settings and update documentation
@wojtekzyla wojtekzyla force-pushed the feat/kafkareceiver-regex-topics branch from ec5d0d9 to 0eb64bd Compare January 7, 2025 11:36
@wojtekzyla wojtekzyla requested a review from JaredTan95 January 8, 2025 10:04
Copy link
Contributor

@MovieStoreGuy MovieStoreGuy left a comment

Choose a reason for hiding this comment

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

For this kind of change an issue is required so there can be a discussion on it.

I have concerns on future maintainability of the receiver including a feature like this and potential expectations on how it should work.

My preference is a feature like this should be done within the receiver creator using an Observer and not to complicate the Kafka configuration further.

@wojtekzyla wojtekzyla closed this Jan 16, 2025
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.

4 participants