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

Refactor mongodb module to align with other modules #1

Open
wants to merge 1 commit into
base: mongodb_multihost_32188
Choose a base branch
from

Conversation

shmsr
Copy link

@shmsr shmsr commented Apr 24, 2023

After some testing and debugging the new changes made to beats, we found that how clientOptions was initialized twice and lots of operations were happening for every Fetch although it's the same across all metricsets. Also the naming of the structs were off.

mongodb module's implementation was not as standard as other modules like beat, aerospike, etc. So, as per Boy Scout Rule, it was important that we should ideally first fix this problem so that no technical debt is there when we are making the actual change. With the new changes, it was easier to do the new changes related to adding multi-host support for mongodb module. Also, these changes fixes the issues that we found during testing.

cc: @ritalwar

if parts := strings.SplitN(host, "://", 2); len(parts) != 2 {
host = "mongodb://" + host // add scheme
}
if err := clientOptions.ApplyURI(host).Validate(); err != nil {
Copy link
Author

Choose a reason for hiding this comment

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

ApplyURI is purposedly put here because as per the documentation, any methods on clientOptions i.e, of SetXXX form overrides the URI parameters (if any) and vice-versa. So it would give the user freedom to set as desired parameters using the URI itself and it overrides the values of the fields that were set using SetXXX

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.

1 participant