Skip to content

Allow instantiating extensions in separate configs #8394

Open
@evan-bradley

Description

@evan-bradley

Is your feature request related to a problem? Please describe.

There is currently no way to easily instantiate extensions across multiple configuration sources. The default behavior in koanf is to overwrite slices when merging multiple maps. This results in behavior where the service.extensions key will be overridden and take the value of the final source if it is set multiple times.

Take the following two configuration files:

extensions:
  health_check:
    endpoint: localhost:61234

service:
  extensions: [health_check]
extensions:
  zpages:

service:
  extensions: [zpages]

If I start the Collector with the following, only the zpages extension will be started.

otelcol --config=health_check.yaml --config=zpages.yaml

The effective config will look like:

extensions:
  health_check:
    endpoint: localhost:61234
  zpages:

service:
  extensions: [zpages]

Describe the solution you'd like
At a minimum, provide a naming scheme similar to what we provide for pipelines to allow config sources to instantiate extensions they define. This could look like:

service:
  extensions/health: [health_check]
  extensions/zpages: [zpages]

Describe alternatives you've considered

A more comprehensive solution could be to override the default koanf merging strategy to support merging slices. I would propose the following rules for merging slices:

  1. Slices values are not deduplicated
  2. Slices are merged by appending slices to previous values.

The caveat with changing this behavior is that it would be more difficult to set slice values to empty lists, which would now require setting to nil (or another primitive value) before setting them to an empty list.

We could also simply recommend that extensions are all instantiated in a single file, but in my view this is not a good solution.

Additional context

It's possible I've missed an existing mechanism for this, but I've looked through the code and docs and don't see an any way to accomplish this. If I've missed something we should make it more visible.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions