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 OpAMP bridge logging and configuration #2196

Merged
merged 12 commits into from
Oct 11, 2023

Conversation

jaronoff97
Copy link
Contributor

@jaronoff97 jaronoff97 commented Oct 5, 2023

As a side quest from #1368, this PR changes how config is loaded in to the bridge as well as the logging structure.

This has some breaking changes around the config. This is okay because currently no one is running the bridge (AFAIK!)

components_allowed => componentsAllowed
protocol which is now inferred from endpoint
capabilities []string => map[Capability]bool for enhanced configuration validation

@jaronoff97 jaronoff97 requested a review from a team October 5, 2023 16:04
Copy link
Member

@srikanthccv srikanthccv left a comment

Choose a reason for hiding this comment

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

LGTM

@avadhut123pisal
Copy link
Contributor

@jaronoff97 What is your view on #1559 (comment) ? Because, that would require change in the OpAMP bridge code as well as in the Operator.

@jaronoff97
Copy link
Contributor Author

jaronoff97 commented Oct 6, 2023

@avadhut123pisal @srikanthccv i like the recommendation, but rather than using a struct, i'm going to use an enum and then a map from enum -> bool. This provides the same YAML interface, but is much cleaner to work with in code because I don't need to explicitly check the presence of each field.

@srikanthccv
Copy link
Member

My reasoning behind using typed struct is as the bridge implementation improves, we will find ourselves checking if a capability exists before performing certain actions (for instance, AcceptConnectionSettings).

I find it better to do some like if b.Capabilities.AcceptsRemoteConfig than enumerating the options and comparing.

@jaronoff97
Copy link
Contributor Author

We are able to do that with a map check with an enum as well. I'm trying to avoid needing to do an if on every struct field for validation or defaulting.

@srikanthccv
Copy link
Member

I am more biased towards the end user's POV/experience than what needs to be done in our codebase. The enums/strings are prone to typos. The struct makes it clear about the fixed set of capabilities that the user can enable or disable and works nicely with the IDE yaml schema generation and validation. I don't have a strong opinion. I am fine with either of the approaches.

@jaronoff97
Copy link
Contributor Author

jaronoff97 commented Oct 10, 2023

Using a map is the same user experience while also being more ergonomic for use in go by creating constants for each capability. We also only use these types as an intermediary for the actual capabilities struct which has what you are asking for.

Copy link
Contributor

@avadhut123pisal avadhut123pisal left a comment

Choose a reason for hiding this comment

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

LGTM :)

cmd/operator-opamp-bridge/agent/agent.go Outdated Show resolved Hide resolved
cmd/operator-opamp-bridge/agent/agent.go Outdated Show resolved Hide resolved
cmd/operator-opamp-bridge/main.go Outdated Show resolved Hide resolved
@jaronoff97 jaronoff97 requested a review from gdfast October 10, 2023 18:44
Copy link
Contributor

@gdfast gdfast left a comment

Choose a reason for hiding this comment

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

LGTM!

cmd/operator-opamp-bridge/config/config.go Outdated Show resolved Hide resolved
cmd/operator-opamp-bridge/config/config.go Show resolved Hide resolved
# Use pipe (|) for multiline entries.
subtext: |
`components_allowed` => `componentsAllowed`
:x: `protocol` which is now inferred from endpoint
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 :x: mean? Does it mean that is has been removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes

@jaronoff97 jaronoff97 merged commit 888948f into open-telemetry:main Oct 11, 2023
24 checks passed
ItielOlenick pushed a commit to ItielOlenick/opentelemetry-operator that referenced this pull request May 1, 2024
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.

5 participants