You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- `${VAR}`-- substitute the value of environment variable `VAR`
1917
+
- `${VAR:-fallback}`-- substitute `VAR`, or `fallback` if `VAR` is undefined,
1918
+
empty, or null
1919
+
- `$$`-- escape sequence producing a literal `$`; the resolved `$` is not
1920
+
considered for further substitution matching
1921
+
- Substitution applies only to scalar values, not mapping keys
1922
+
- Substitution is not recursive -- the result of one substitution is not
1923
+
scanned for further `${...}` references
1924
+
- YAML structure injection via env vars is prohibited -- substituted values
1925
+
are always scalars
1926
+
- Node types are interpreted after substitution (e.g. `${BOOL_VALUE}` where
1927
+
`BOOL_VALUE=true`resolves to YAML boolean `true`, not string `"true"`)
1928
+
- Invalid substitution references (e.g. `${VAR:?error}`) must produce a parse
1929
+
error with no partial results
1930
+
- The optional `env:` prefix is supported: `${env:VAR}`is equivalent to
1931
+
`${VAR}`
1932
+
1933
+
#### I.1.2 Implementation Approach
1934
+
1935
+
The substitution should be implemented within the custom YAML
1936
+
`IConfigurationProvider`. The processing order is:
1937
+
1938
+
```text
1939
+
1. Read YAML file from disk
1940
+
2. Perform ${VAR:-default} substitution on all scalar values
1941
+
3. Parse substituted YAML into IConfiguration key/value pairs
1942
+
4. Expose via standard IConfigurationProvider interface
1943
+
```
1944
+
1945
+
Step 2 processes the raw YAML text (or the parsed YAML DOM scalar nodes)
1946
+
before projecting into `IConfiguration`. This ensures type coercion happens
1947
+
after substitution, matching the spec requirement.
1948
+
1949
+
#### I.1.3 Interplay with IConfiguration Environment Variable Loading
1950
+
1951
+
The SDK currently uses a vendored `EnvironmentVariablesConfigurationProvider` to
1952
+
make `OTEL_*` env vars available as `IConfiguration` keys. When `OTEL_CONFIG_FILE`
1953
+
is active, these two env-var mechanisms overlap:
1954
+
1955
+
| Mechanism | When it runs | What it does |
1956
+
| --- | --- | --- |
1957
+
| YAML `${VAR}` substitution | YAML parse time | Replaces placeholders in YAML scalar values with env var values |
1958
+
| `EnvironmentVariablesConfigurationProvider` | `IConfiguration` build time | Makes all `OTEL_*` env vars available as `IConfiguration` keys that can override options |
1959
+
1960
+
The spec states that when `OTEL_CONFIG_FILE` is set, the config file is the
1961
+
authoritative source and environment variables should not override values
The spec provides a comprehensive examples table that can be translated
1999
+
directly into test cases.
2000
+
2001
+
### I.2 Schema Validation Requirements
2002
+
2003
+
The spec requires two distinct validation layers, only one of which the current
2004
+
design addresses.
2005
+
2006
+
#### I.2.1 Two-Layer Validation Model
2007
+
2008
+
| Layer | What it validates | When it runs | Current status |
2009
+
| --- | --- | --- | --- |
2010
+
| **Schema validation** | YAML structure conforms to the config data model: required fields present, types correct, no unknown keys, valid nesting | During Parse, before values enter `IConfiguration` | **Not addressed** |
2011
+
| **Options validation** | Individual option values are semantically valid: port in range, endpoint is valid URI, sampler arg in `[0.0, 1.0]` | During `DelegatingOptionsFactory.Create`, via `IValidateOptions<T>` | Addressed in [Risk 1.1](configuration-analysis-risks.md#11-options-validation-is-completely-absent) (Step 0a) |
2012
+
2013
+
Both layers are needed. Schema validation catches structural problems early
2014
+
(before any SDK component construction). Options validation catches semantic
2015
+
problems that schema alone cannot express.
2016
+
2017
+
#### I.2.2 Schema Validation Implementation
2018
+
2019
+
The spec's configuration data model is defined as a [JSON
0 commit comments