mirror of
https://github.com/hanzoai/telemetry.git
synced 2026-10-30 20:01:49 +00:00
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. <!-- Issue number if applicable --> #### Link to tracking issue Related issues: - https://github.com/open-telemetry/opentelemetry-collector/issues/8754 - https://github.com/open-telemetry/opentelemetry-collector/issues/8394 - https://github.com/open-telemetry/opentelemetry-collector/issues/10370 <!--Describe what testing was performed and which tests were added.--> #### Testing - Added <!--Describe the documentation added.--> #### Documentation - Added under readme. ##### Example Consider the following configs, ```yaml # 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 ] ``` ```yaml # 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: ```yaml # 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 š
210 lines
3.7 KiB
YAML
210 lines
3.7 KiB
YAML
- name: merge-mode-default
|
|
configs:
|
|
-
|
|
receivers:
|
|
nop:
|
|
nop/myreceiver:
|
|
|
|
processors:
|
|
nop:
|
|
nop/myprocessor:
|
|
|
|
exporters:
|
|
nop:
|
|
nop/myexporter:
|
|
|
|
extensions:
|
|
nop:
|
|
nop/myextension:
|
|
|
|
service:
|
|
extensions: [nop]
|
|
pipelines:
|
|
traces:
|
|
receivers: [nop]
|
|
processors: [nop]
|
|
exporters: [nop]
|
|
-
|
|
receivers:
|
|
nop2:
|
|
|
|
exporters:
|
|
nop2:
|
|
|
|
extensions:
|
|
nop2:
|
|
|
|
service:
|
|
extensions: [nop2]
|
|
pipelines:
|
|
traces:
|
|
receivers: [nop2]
|
|
processors: [nop2]
|
|
exporters: [nop2]
|
|
expected:
|
|
receivers:
|
|
nop2:
|
|
nop:
|
|
nop/myreceiver:
|
|
|
|
exporters:
|
|
nop2:
|
|
nop:
|
|
nop/myexporter:
|
|
|
|
processors:
|
|
nop:
|
|
nop/myprocessor:
|
|
|
|
extensions:
|
|
nop2:
|
|
nop:
|
|
nop/myextension:
|
|
|
|
service:
|
|
extensions: [nop2]
|
|
pipelines:
|
|
traces:
|
|
receivers: [nop2]
|
|
processors: [nop2]
|
|
exporters: [nop2]
|
|
- name: merge-mode-append
|
|
append_paths: ["service"]
|
|
configs:
|
|
-
|
|
receivers:
|
|
nop:
|
|
key: val
|
|
|
|
processors:
|
|
nop:
|
|
|
|
exporters:
|
|
nop:
|
|
key: 2
|
|
|
|
extensions:
|
|
nop:
|
|
|
|
service:
|
|
extensions: [nop]
|
|
pipelines:
|
|
traces:
|
|
receivers: [nop]
|
|
processors: [nop]
|
|
exporters: [nop]
|
|
-
|
|
receivers:
|
|
nop2:
|
|
|
|
exporters:
|
|
nop2:
|
|
nop:
|
|
key: updated_value
|
|
|
|
extensions:
|
|
nop2:
|
|
|
|
service:
|
|
extensions: [nop2]
|
|
pipelines:
|
|
traces:
|
|
receivers: [nop2]
|
|
processors: [nop2]
|
|
exporters: [nop2]
|
|
expected:
|
|
receivers:
|
|
nop2:
|
|
nop:
|
|
key: val
|
|
|
|
exporters:
|
|
nop2:
|
|
nop:
|
|
key: updated_value
|
|
|
|
processors:
|
|
nop:
|
|
|
|
extensions:
|
|
nop2:
|
|
nop:
|
|
|
|
service:
|
|
extensions: [nop2]
|
|
pipelines:
|
|
traces:
|
|
receivers: [nop2]
|
|
processors: [nop2]
|
|
exporters: [nop2]
|
|
- name: merge-mode-append-override-old-values
|
|
append_paths: ["service"]
|
|
configs:
|
|
-
|
|
receivers:
|
|
nop:
|
|
key1: "value"
|
|
key2: 1
|
|
|
|
processors:
|
|
nop:
|
|
|
|
exporters:
|
|
nop:
|
|
|
|
extensions:
|
|
nop:
|
|
ext:
|
|
key: 1
|
|
|
|
service:
|
|
extensions: [nop, ext]
|
|
pipelines:
|
|
traces:
|
|
receivers: [nop]
|
|
processors: [nop]
|
|
exporters: [nop]
|
|
-
|
|
receivers:
|
|
nop2:
|
|
|
|
exporters:
|
|
nop2:
|
|
|
|
extensions:
|
|
ext:
|
|
key: 2
|
|
|
|
service:
|
|
extensions: [ext]
|
|
pipelines:
|
|
traces:
|
|
receivers: [nop2]
|
|
exporters: [nop2]
|
|
expected:
|
|
receivers:
|
|
nop:
|
|
key1: "value"
|
|
key2: 1
|
|
nop2:
|
|
|
|
exporters:
|
|
nop2:
|
|
nop:
|
|
|
|
processors:
|
|
nop:
|
|
|
|
extensions:
|
|
nop:
|
|
ext:
|
|
key: 2
|
|
|
|
service:
|
|
extensions: [ext]
|
|
pipelines:
|
|
traces:
|
|
receivers: [nop2]
|
|
processors: [nop]
|
|
exporters: [nop2]
|