-
Notifications
You must be signed in to change notification settings - Fork 46
Refactor Otel Collector Googlecloud ConfigMap Generation #1665
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
base: main
Are you sure you want to change the base?
Conversation
Skipping CI for Draft Pull Request. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/test all |
a856164
to
ad2bcb3
Compare
…ruct and YAML Marshaling Refactor the generation of the otel-collector Googlecloud ConfigMap to construct the configuration using a Go map and marshal it to YAML, replacing the previous approach of using a static YAML string. This change improves maintainability and reduces the risk of formatting errors in the generated config. Add GooglecloudCollectorConfigYAML() in pkg/metrics/otel.go to build the config as a Go map and marshal it to YAML. Update OtelReconciler in pkg/reconcilermanager/controllers/otel_controller.go to use the new function when creating/updating the ConfigMap. Update related tests to use the new function for expected config values. Deprecate the old CollectorConfigGooglecloud string constant. This refactor makes the config generation more robust and easier to extend or validate in the future.
) | ||
|
||
// CollectorConfigGooglecloudYAML returns the otel-collector-googlecloud config as YAML. | ||
func CollectorConfigGooglecloudYAML() (string, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like valid configs can be generated programmatically, e.g. https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/extension/healthcheckextension/factory.go#L20
Would it be possible for us to use that to generate canonical/valid configs and then marshal to YAML?
) | ||
|
||
// CollectorConfigGooglecloudYAML returns the otel-collector-googlecloud config as YAML. | ||
func CollectorConfigGooglecloudYAML() (string, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a unit test for this function which validates the output yaml string against a static/hardcoded test yaml string? That will make it easier for a human reviewer to inspect the actual output yaml
To Use Go Struct and YAML Marshaling
Refactor the generation of the otel-collector Googlecloud ConfigMap to construct the configuration using a Go map and marshal it to YAML, replacing the previous approach of using a static YAML string. This change improves maintainability and reduces the risk of formatting errors in the generated config. Add GooglecloudCollectorConfigYAML() and deprecate the old CollectorConfigGooglecloud string constant. This refactor makes the config generation more robust and easier to extend or validate in the future.