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

[confmap] - new command line argument for append merging strategy #12097

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

VihasMakwana
Copy link
Contributor

@VihasMakwana VihasMakwana commented Jan 15, 2025

Koanf's default merging strategy currently overrides static values such as slices, numbers, and strings. However, lists of components should be treated as a special case. This pull request introduces a new feature gate to allow for merging lists instead of discarding the existing ones.

With this new merging strategy:

  • Lists under the service configuration are merged rather than replaced.
  • The merging logic is name-aware, meaning that if components with the same name appear in both lists, they will only appear once in the final merged list.
  • This strategy only affects configurations under service::*.

Link to tracking issue

Related issues:

Testing

  • Added

Documentation

  • To be added

Usage Examples

  1. otelcol --config config1.yaml --config config2.yaml --merge-paths-append "service"
    • This will merge lists (instead of overwriting) under the service path in the config.
  2. otelcol --config config1.yaml --config config2.yaml --merge-paths-append "processor::transform::log_statements"
    • This will only merge lists at processor::transform::log_statements path in the config. It will not affect any other config paths.
  3. otelcol --config config1.yaml --config config2.yaml --merge-paths-append "*"
    • This will merge all the lists encountered in the given config.
  4. otelcol --config config1.yaml --config config2.yaml --merge-paths-append "processor::transform::log_statements" --merge-paths-append "service"
    • You can also use combination of paths like this example. It is a combination of example 1 and 2.

For backward compatibly, the default behaviour is not to merge lists. Users who want to explicitly merge lists can enable the command line option.

Note: I’d appreciate your feedback on this 🙏

@VihasMakwana VihasMakwana requested review from evan-bradley, a team and mx-psi as code owners January 15, 2025 13:52
confmap/confmap.go Outdated Show resolved Hide resolved
@VihasMakwana
Copy link
Contributor Author

@Aneurysm9 @evan-bradley @mx-psi can you take another look?

i've removed feature flag and added command line argument to control the paths user wants merged.

I'll work on the documentation once we've established a common ground.

Copy link

codecov bot commented Jan 27, 2025

Codecov Report

Attention: Patch coverage is 97.45763% with 3 lines in your changes missing coverage. Please review.

Project coverage is 91.87%. Comparing base (30b8d53) to head (5685baa).
Report is 9 commits behind head on main.

Files with missing lines Patch % Lines
confmap/merge.go 96.59% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #12097      +/-   ##
==========================================
+ Coverage   91.84%   91.87%   +0.02%     
==========================================
  Files         465      466       +1     
  Lines       25325    25442     +117     
==========================================
+ Hits        23261    23375     +114     
- Misses       1675     1677       +2     
- Partials      389      390       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@VihasMakwana VihasMakwana changed the title [confmap] - new feature flag for append merging strategy [confmap] - new command line argument for append merging strategy Jan 28, 2025
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.

3 participants