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

Introduce simplified parsers #2972

Merged
merged 7 commits into from
Jun 3, 2024

Conversation

jaronoff97
Copy link
Contributor

Description:
This is the first part of a multi-PR effort to simplify how parsing configuration blocks works. This is accomplished by massively reducing the toil of creating new parsers and limiting the state objects need to hold on to. Right now, none of these new components are being used, as that will be isolated for a follow up.

Link to tracking Issue(s): #2603

Testing: many unit tests

Documentation: n/a

@jaronoff97 jaronoff97 added the Skip Changelog PRs that do not require a CHANGELOG.md entry label May 20, 2024
@jaronoff97 jaronoff97 requested a review from a team as a code owner May 20, 2024 19:10
@jaronoff97
Copy link
Contributor Author

jaronoff97 commented May 20, 2024

Screenshot 2024-05-20 at 3 30 59 PM

This has 100% test coverage where 90% of those tests were copied from the previous package.

Copy link
Contributor

@iblancasa iblancasa left a comment

Choose a reason for hiding this comment

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

Thanks for this work. Ping me if you need help for the rest of components

@jaronoff97
Copy link
Contributor Author

@iblancasa can do :D I want to land this, then do exporters, then do processors and then migrate over to use this. You can see an example of the usage here

Copy link
Contributor

@swiatekm swiatekm left a comment

Choose a reason for hiding this comment

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

Looks good to me overall, had some questions, and some comments about style.

internal/components/component.go Outdated Show resolved Hide resolved
internal/components/component.go Outdated Show resolved Hide resolved
internal/components/component.go Outdated Show resolved Hide resolved
internal/components/component.go Outdated Show resolved Hide resolved
internal/components/component.go Outdated Show resolved Hide resolved
internal/components/single_endpoint.go Outdated Show resolved Hide resolved
internal/components/multi_endpoint.go Show resolved Hide resolved
Copy link
Contributor

@swiatekm swiatekm left a comment

Choose a reason for hiding this comment

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

LGTM, minor comment on the port parsing notwithstanding.

if r.MatchString(endpoint) {
portStr := r.FindString(endpoint)
cleanedPortStr := strings.Replace(portStr, ":", "", -1)
port, err = strconv.ParseInt(cleanedPortStr, 10, 32)
Copy link
Contributor

Choose a reason for hiding this comment

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

Port numbers are 16-bit integers, so this should really be 16 instead of 32. We should also check if the value isn't negative.

In general, is there a reason not to use https://pkg.go.dev/net#SplitHostPort for parsing here, instead of the regex?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this was copied over from the existing code, but i can swap it :)

Copy link
Contributor Author

@jaronoff97 jaronoff97 May 31, 2024

Choose a reason for hiding this comment

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

actually the problem with net.SplitHostPort is that it doesn't handle the case where it contains a scheme at the beginning (obv not a major issue) but that probably is why it wasn't used initially. The code ends up being the same here actually, so I think I may stick with this just changing to a 16 bit int... actually i think we need to use 32 bits here because otherwise we get an out of range error:

strconv.ParseInt: parsing "65535": value out of range

(ex)

@jaronoff97 jaronoff97 merged commit 4723c17 into open-telemetry:main Jun 3, 2024
33 checks passed
@jaronoff97 jaronoff97 deleted the another-try-sob branch June 5, 2024 15:56
ItielOlenick pushed a commit to ItielOlenick/opentelemetry-operator that referenced this pull request Jun 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Skip Changelog PRs that do not require a CHANGELOG.md entry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants