[File configuration] Alternate proposal for config.yaml, including merges #3920
Labels
area:configuration
Related to configuring the SDK
spec:miscellaneous
For issues that don't match any other spec label
All,
Please find here an alternate proposal to address how to use environment variables,
and merge changes, with a
config.yaml
configuration file.Using an issue for discussion.
Related to:
cc @jack-berg
Environment variable
OTEL_CONFIG_FILE
is defined.Every other environment variable defined in the SDK as of today is
ignored, in the low level SDK implementation.
The yaml configuration file supports env var substitution, with default
values.
For example:
A
config.yaml
template is deliveredFor all the existing SDK environment variables defined today,
sort them in two categories:
5.1. SDK variables that it make sense to still honor from config.yaml
For example,
OTEL_EXPORTER_OTLP_TRACES_PROTOCOL
is in this category,because it controls a yaml node scalar that can be used with substitution.
These SDK environment variables are henceforth referred to as "legacy".
5.2. SDK variables that it does not make sense to keep in config.yaml
For example,
OTEL_TRACES_EXPORTER
is in this category,because it controls an intermediate structural node in the config, not a
leaf scalar.
Yaml is a better way to describe children of exporter,
OTEL_TRACES_EXPORTER
is not suited for that, and is abandoned.
in the applicable nodes in config.yaml.
For example:
This will show to users how to convert an existing configuration, based on
legacy env vars, into a working config.yaml.
This also avoids the trap of forcefully mapping a flat list of env vars into
a tree structure:
what is supported by legacy today, at end user option.
For example:
Note the net effect here:
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT
is not used because it is hardcoded in the SDK.
As a bonus, every SIG that did not implement some config variable (see the
spec compatibility matrix) is now compliant, since all variables are supported from yaml,
without SDK changes (except for supporting yaml of course).
default value defined as fallback.
This ensures the config is still valid if an environment variable is not
set, which is helpful and corresponds to the behavior today with legacy
variables.
A "merge" is an operation when a configuration overlay is applied on top of an existing configuration.
A typical use case is when:
config.yaml
Disclaimer:
This section is not prototyped yet, but I think we can do better and have a
syntax closer to yaml including to express merges.
How to deal with arrays is not defined yet, I just wrote this 2 hours
after the configuration SIG meeting on 2024-03-04, bear with me.
The idea of multiple export PATH_TO_YAML_NODE="value" syntax is abandoned.
Instead, a configuration override on top of an existing config.yaml is
expressed in one yaml document.
8.1. Environment variable
OTEL_CONFIG_MERGE
contains the config to merge.Having text with \n inside an env var seems doable (to confirm), as in:
Alternate, point to a
config_merge.yaml
file.8.2. The config_merge.yaml document has a different schema, to describe
changes to apply on top of config.yaml
8.3. Top level merge actions
The merge doc contains:
8.4. Remove actions
Here, the full path to the node to remove is given
(tracer_provider.sampler.parent_based).
The
parent_based
node is removed, because it is a leaf in theremove
tree.Multiple leaf removals can be expressed in the same
remove
tree (not shown, similar to change below)8.5. Change actions
This syntax is to be compared with:
The two scalars
attribute_count_limit
andevent_count_limit
are changed, because they appear as leafs in thechange
tree.The change tree can contain multiple changes, for example:
8.6. Add actions
8.7. Complete merge example
A couple of points to note:
config.yaml, which is a good news for users (no dual env var syntax to learn)
merge docs (unlike env vars)
does not changes the tree structure but only sets a leaf node
trace_id_ratio_based sampler here) is done as a remove + add action
additions (for example, for point is to remove before add).
When is merge useful ?
Assume an existing configuration that uses a scalar value, with no provisions for a substitution variable:
The merge can replace
200
with300
, or better, replace200
with${MY_ATTRIBUTE_COUNT_LIMIT:300}
, so that the modified configuration file is easier to use.Another major use case is to replace en entire subtree in the yaml configuration:
8.8. Possible extensions
Several merges can be applied in a chain, using a collection of merge
documents.
For example:
The text was updated successfully, but these errors were encountered: