|
| 1 | +# Supplementary Guidelines |
| 2 | + |
| 3 | +Note: this document is NOT a spec, it is provided to support the declarative config |
| 4 | +[API](./api.md) and [SDK](./sdk.md) specifications, it does NOT add any extra |
| 5 | +requirements to the existing specifications. |
| 6 | + |
| 7 | +<details> |
| 8 | +<summary>Table of Contents</summary> |
| 9 | + |
| 10 | +<!-- toc --> |
| 11 | + |
| 12 | +- [Configuration interface prioritization and `create`](#configuration-interface-prioritization-and-create) |
| 13 | +- [Programmatic customization and `create`](#programmatic-customization-and-create) |
| 14 | + |
| 15 | +<!-- tocstop --> |
| 16 | + |
| 17 | +</details> |
| 18 | + |
| 19 | +## Configuration interface prioritization and `create` |
| 20 | + |
| 21 | +With the [environment variable](./sdk-environment-variables.md) configuration |
| 22 | +interface, the spec failed to answer the question of whether programmatic or |
| 23 | +environment variable configuration took precedence. This led to differences in |
| 24 | +implementations that were ultimately stabilized and difficult to resolve after |
| 25 | +the fact. |
| 26 | + |
| 27 | +With declarative config, we don't have ambiguity around configuration interface |
| 28 | +precedence: |
| 29 | + |
| 30 | +* [`parse`](./sdk.md#parse) is responsible for parsing config file contents and |
| 31 | + returning the corresponding in-memory data model. Along the way, it |
| 32 | + performs [environment variable substitution](./data-model.md#environment-variable-substitution). |
| 33 | +* [`create`](./sdk.md#create) is responsible for interpreting an in-memory |
| 34 | + config data model and creating SDK components. |
| 35 | + |
| 36 | +There is no precedence ambiguity with the environment variable configuration |
| 37 | +interface: The language of `parse` and `create` is explicit about |
| 38 | +responsibilities and makes no mention of merging environment variables outside |
| 39 | +of environment variable substitution. |
| 40 | +Furthermore, [OTEL_EXPERIMENTAL_CONFIG_FILE](./sdk-environment-variables.md#declarative-configuration) |
| 41 | +explicitly states that the environment variable configuration scheme is ignored. |
| 42 | + |
| 43 | +There is no precedence ambiguity with |
| 44 | +the [programmatic configuration interface](./README.md#programmatic): `create` |
| 45 | +consumes an in-memory config data model and creates SDK components. According to |
| 46 | +the trace, metric, and log specs, SDKs MAY support updating the config, but |
| 47 | +there is no conflict with declarative config which doesn't already exist. |
| 48 | +However, the SDK handles programmatic config updates to SDK components which |
| 49 | +originally programmatically configured applies here as well. If an SDK supports |
| 50 | +it, all programmatic config updates are applied after `create` initializes SDK |
| 51 | +components and therefore take precedence. The semantics of what programmatic |
| 52 | +config updates are allowed and how they merge with existing SDK components are |
| 53 | +out of scope for declarative config. |
| 54 | + |
| 55 | +## Programmatic customization and `create` |
| 56 | + |
| 57 | +While `create` does provide an optional mechanism for programmatic |
| 58 | +customization, its use should be considered a code smell, to be addressed by |
| 59 | +improving the declarative config data model. |
| 60 | + |
| 61 | +For example, the fact that configuration of dynamic authentication for OTLP |
| 62 | +exporters is not possible to express with declarative config should not |
| 63 | +encourage the OpenTelemetry community to have better programmatic customization. |
| 64 | +Instead, we should pursue adding authentication as an SDK extension plugin |
| 65 | +interface and modeling this new plugin in declarative config. |
0 commit comments