Skip to content

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 command line option to allow for merging lists instead of discarding the existing ones.

With this new merging strategy:

  • All the lists 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.

Link to tracking issue

Related issues:

Testing

  • Added

Documentation

  • Added under readme.
Example

Consider the following configs,

# main.yaml
receivers:
  otlp/in:
processors:
  batch:
exporters:
  otlp/out:
extensions:
  file_storage:

service:
  pipelines:
    traces:
      receivers: [ otlp/in ]
      processors: [ batch ]
      exporters: [ otlp/out ]
  extensions: [ file_storage ]
# extra_extension.yaml
extensions:
  healthcheckv2:

service:
  extensions: [ healthcheckv2 ]

If you run the collector with following command,

otelcol --config=main.yaml --config=extra_extension.yaml --feature-gates=-confmap.enableMergeAppendOption

then the final configuration after config resolution will look like following:

# main.yaml
receivers:
  otlp/in:
processors:
  batch:
exporters:
  otlp/out:
extensions:
  file_storage:
  healthcheckv2:

service:
  pipelines:
    traces:
      receivers: [ otlp/in ]
      processors: [ batch ]
      exporters: [ otlp/out ]
  extensions: [ file_storage, healthcheckv2 ]

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 a team, evan-bradley and mx-psi as code owners January 15, 2025 13:52
@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.

@codecov
Copy link

codecov bot commented Jan 27, 2025

Codecov Report

Attention: Patch coverage is 98.18182% with 1 line in your changes missing coverage. Please review.

Project coverage is 92.04%. Comparing base (72878b7) to head (7e731ce).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
confmap/resolver.go 85.71% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #12097      +/-   ##
==========================================
+ Coverage   92.02%   92.04%   +0.01%     
==========================================
  Files         469      470       +1     
  Lines       25318    25372      +54     
==========================================
+ Hits        23299    23353      +54     
  Misses       1612     1612              
  Partials      407      407              

☔ 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
@VihasMakwana VihasMakwana requested a review from dehaansa January 31, 2025 15:05
Copy link
Member

@mx-psi mx-psi 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 taking this Vihas! I have two comments:

  1. I think this is the kind of thing that is hard to get right on the first try, so I would want to do this under some sort of experimental flag.
  2. I would like to do this if possible with little to no modification of stable confmap APIs. confmap is 1.0, it is a very important piece of the Collector, and if we get it wrong it would be quite difficult to reverse course.

@VihasMakwana
Copy link
Contributor Author

@mx-psi Thanks for your comments!

  1. Makes sesne. I will move it under experimental flag.
  2. I understand. I will again take a fresh look and make sure we tick all the boxes.

@VihasMakwana VihasMakwana force-pushed the new-merge-strategy branch 2 times, most recently from 0f66985 to 95913fd Compare February 4, 2025 12:56
Copy link
Member

@dmitryax dmitryax left a comment

Choose a reason for hiding this comment

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

LGTM

@dmitryax
Copy link
Member

Please update the nolint comment to fix CI

@VihasMakwana
Copy link
Contributor Author

A few of test cases are failing but they seem unrelated to my PR.

@VihasMakwana VihasMakwana requested a review from mx-psi March 3, 2025 11:50
@VihasMakwana
Copy link
Contributor Author

@mx-psi I have fixed the the go.mod and I'm not reverting extensionauth. can you please re-review?

@mx-psi mx-psi added this pull request to the merge queue Mar 4, 2025
Merged via the queue into open-telemetry:main with commit 6e82944 Mar 4, 2025
55 checks passed
github-merge-queue bot pushed a commit that referenced this pull request May 5, 2025
…12926)

Follow-up of
#12097

<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
### Description

Ideally, users want to merge lists in pipelines only. In this PR, I'm
adding support for merging following components:
1. extensions
2. receivers
3. exporters

We make use of glob-like pattern to match the path because there can be
multiple pipelines configured. Inspired by @evan-bradley's
[idea](#12097).

I'm leaving `processors` out of this list because we make an ordering
guarantee.

#### _**Future plan:**_ 
Once this PR gets merged, it would make it easier for us to decide upon
the command line flags to make this option configurable over the RFC.
Right now, `patterns` is hardcoded to include above mentioned
components, but we can easily make it configurable after making some
tweaks.

<!-- Issue number if applicable -->
### Link to tracking issue
Relates
#8754

<!--Describe what testing was performed and which tests were added.-->
### Testing

Expanded the existing test cases

<!--Describe the documentation added.-->
#### Documentation
github-merge-queue bot pushed a commit that referenced this pull request Sep 17, 2025
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description

This RFC is a follow-up of
#12097.
The first PR introduced the feature gate to merge the components' lists
and left out the options to configure the merging behaviour.

This RFC proposes an approach to extend the current behaviour by
enabling merging of specified config parts and support different modes.

<!-- Issue number if applicable -->
#### Link to tracking issue
Relates:
- #8754
- #8394
- #10370


Thanks to @mx-psi @dmitryax and @evan-bradley for their feedback on the
[first
PR](#12097)!!

---------

Co-authored-by: Pablo Baeyens <[email protected]>
Co-authored-by: Evan Bradley <[email protected]>
Co-authored-by: Hélia Barroso <[email protected]>
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.

6 participants