Skip to content

Commit aafb77a

Browse files
authored
Define OTEL_EXPERIMENTAL_CONFIG_FILE to ignore other env vars, add env var substitution default syntax (#3948)
Fixes #3752. Implementation of the configuration working group recommendation as [described here](#3752 (comment)). - Adds definition for `OTEL_EXPERIMENTAL_CONFIG_FILE `, which ignores other env vars when evaluating, except env var substitution references - Adds new env var substitution default syntax `${ENVVAR:-defaultValue}` - Paired with open-telemetry/opentelemetry-configuration#76, which defines a new [sdk-config.yaml](https://github.com/jack-berg/opentelemetry-configuration/blob/starter-template/examples/sdk-config.yaml) starter template referencing all env vars that map cleanly.
1 parent 3c2eaae commit aafb77a

File tree

3 files changed

+116
-62
lines changed

3 files changed

+116
-62
lines changed

spec-compliance-matrix.md

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -269,37 +269,38 @@ Disclaimer: this list of features is still a work in progress, please refer to t
269269

270270
Note: Support for environment variables is optional.
271271

272-
| Feature | Go | Java | JS | Python | Ruby | Erlang | PHP | Rust | C++ | .NET | Swift |
273-
|----------------------------------------------------------|-----|------|-----|-------------|------|--------|-----|------|-----|------|-------|
274-
| OTEL_SDK_DISABLED | - | + | - | - | - | - | + | - | - | - | - |
275-
| OTEL_RESOURCE_ATTRIBUTES | + | + | + | + | + | + | + | + | + | + | - |
276-
| OTEL_SERVICE_NAME | + | + | + | + | + | + | + | | + | + | |
277-
| OTEL_LOG_LEVEL | - | - | + | [-][py1059] | + | - | + | | - | - | - |
278-
| OTEL_PROPAGATORS | - | + | | + | + | + | + | - | - | - | - |
279-
| OTEL_BSP_* | + | + | + | + | + | + | + | + | - | + | - |
280-
| OTEL_BLRP_* | | + | | | | | | + | | + | |
281-
| OTEL_EXPORTER_OTLP_* | + | + | | + | + | + | + | + | + | + | - |
282-
| OTEL_EXPORTER_ZIPKIN_* | - | + | | + | + | - | + | - | - | + | - |
283-
| OTEL_TRACES_EXPORTER | - | + | + | + | + | + | + | - | - | - | |
284-
| OTEL_METRICS_EXPORTER | - | + | | + | - | - | + | - | - | - | - |
285-
| OTEL_LOGS_EXPORTER | - | + | | + | | | + | | | - | |
286-
| OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT | + | + | + | + | + | + | + | + | - | + | |
287-
| OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT | + | + | + | + | + | + | + | | | + | |
288-
| OTEL_SPAN_EVENT_COUNT_LIMIT | + | + | + | + | + | + | + | + | - | + | |
289-
| OTEL_SPAN_LINK_COUNT_LIMIT | + | + | + | + | + | + | + | + | - | + | |
290-
| OTEL_EVENT_ATTRIBUTE_COUNT_LIMIT | + | - | | + | + | + | + | | | + | |
291-
| OTEL_LINK_ATTRIBUTE_COUNT_LIMIT | + | - | | + | + | + | + | | | + | |
292-
| OTEL_LOGRECORD_ATTRIBUTE_COUNT_LIMIT | | | | | | | + | | | | |
293-
| OTEL_LOGRECORD_ATTRIBUTE_VALUE_LENGTH_LIMIT | | | | | | | + | | | | |
294-
| OTEL_TRACES_SAMPLER | + | + | + | + | + | + | + | - | - | - | |
295-
| OTEL_TRACES_SAMPLER_ARG | + | + | + | + | + | + | + | - | - | - | |
296-
| OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT | + | + | + | + | + | - | + | | | + | |
297-
| OTEL_ATTRIBUTE_COUNT_LIMIT | + | + | + | + | + | - | + | | | + | |
298-
| OTEL_METRIC_EXPORT_INTERVAL | - | + | | | | | + | | | + | |
299-
| OTEL_METRIC_EXPORT_TIMEOUT | - | - | | | | | + | | | + | |
300-
| OTEL_METRICS_EXEMPLAR_FILTER | - | + | | | | | + | | | - | |
301-
| OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE | - | + | + | + | | | + | | | + | |
302-
| OTEL_EXPORTER_OTLP_METRICS_DEFAULT_HISTOGRAM_AGGREGATION | | + | | | | | | | | | |
272+
| Feature | Go | Java | JS | Python | Ruby | Erlang | PHP | Rust | C++ | .NET | Swift |
273+
|----------------------------------------------------------|----|------|----|-------------|------|--------|-----|------|-----|------|-------|
274+
| OTEL_SDK_DISABLED | - | + | - | - | - | - | + | - | - | - | - |
275+
| OTEL_RESOURCE_ATTRIBUTES | + | + | + | + | + | + | + | + | + | + | - |
276+
| OTEL_SERVICE_NAME | + | + | + | + | + | + | + | | + | + | |
277+
| OTEL_LOG_LEVEL | - | - | + | [-][py1059] | + | - | + | | - | - | - |
278+
| OTEL_PROPAGATORS | - | + | | + | + | + | + | - | - | - | - |
279+
| OTEL_BSP_* | + | + | + | + | + | + | + | + | - | + | - |
280+
| OTEL_BLRP_* | | + | | | | | | + | | + | |
281+
| OTEL_EXPORTER_OTLP_* | + | + | | + | + | + | + | + | + | + | - |
282+
| OTEL_EXPORTER_ZIPKIN_* | - | + | | + | + | - | + | - | - | + | - |
283+
| OTEL_TRACES_EXPORTER | - | + | + | + | + | + | + | - | - | - | |
284+
| OTEL_METRICS_EXPORTER | - | + | | + | - | - | + | - | - | - | - |
285+
| OTEL_LOGS_EXPORTER | - | + | | + | | | + | | | - | |
286+
| OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT | + | + | + | + | + | + | + | + | - | + | |
287+
| OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT | + | + | + | + | + | + | + | | | + | |
288+
| OTEL_SPAN_EVENT_COUNT_LIMIT | + | + | + | + | + | + | + | + | - | + | |
289+
| OTEL_SPAN_LINK_COUNT_LIMIT | + | + | + | + | + | + | + | + | - | + | |
290+
| OTEL_EVENT_ATTRIBUTE_COUNT_LIMIT | + | - | | + | + | + | + | | | + | |
291+
| OTEL_LINK_ATTRIBUTE_COUNT_LIMIT | + | - | | + | + | + | + | | | + | |
292+
| OTEL_LOGRECORD_ATTRIBUTE_COUNT_LIMIT | | | | | | | + | | | | |
293+
| OTEL_LOGRECORD_ATTRIBUTE_VALUE_LENGTH_LIMIT | | | | | | | + | | | | |
294+
| OTEL_TRACES_SAMPLER | + | + | + | + | + | + | + | - | - | - | |
295+
| OTEL_TRACES_SAMPLER_ARG | + | + | + | + | + | + | + | - | - | - | |
296+
| OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT | + | + | + | + | + | - | + | | | + | |
297+
| OTEL_ATTRIBUTE_COUNT_LIMIT | + | + | + | + | + | - | + | | | + | |
298+
| OTEL_METRIC_EXPORT_INTERVAL | - | + | | | | | + | | | + | |
299+
| OTEL_METRIC_EXPORT_TIMEOUT | - | - | | | | | + | | | + | |
300+
| OTEL_METRICS_EXEMPLAR_FILTER | - | + | | | | | + | | | - | |
301+
| OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE | - | + | + | + | | | + | | | + | |
302+
| OTEL_EXPORTER_OTLP_METRICS_DEFAULT_HISTOGRAM_AGGREGATION | | + | | | | | | | | | |
303+
| OTEL_EXPERIMENTAL_CONFIG_FILE | | | | | | | | | | | |
303304

304305
## File Configuration
305306

specification/configuration/file-configuration.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ Configuration files support environment variables substitution for references
7272
which match the following regular expression:
7373

7474
```regexp
75-
\$\{(?<ENV_NAME>[a-zA-Z_][a-zA-Z0-9_]*)}
75+
\$\{(?<ENV_NAME>[a-zA-Z_][a-zA-Z0-9_]*)(:-(?<DEFAULT_VALUE>[^\n]*))?}
7676
```
7777

7878
The `ENV_NAME` MUST start with an alphabetic or `_` character, and is followed
@@ -84,8 +84,11 @@ invalid.
8484
Environment variable substitution MUST only apply to scalar values. Mapping keys
8585
are not candidates for substitution.
8686

87-
If a referenced environment variable is not defined, it MUST be replaced with an
88-
empty value.
87+
The `DEFAULT_VALUE` is an optional fallback value which is substituted
88+
if `ENV_NAME` is null, empty, or undefined. `DEFAULT_VALUE` consists of 0 or
89+
more non line break characters (i.e. any character except `\n`). If a referenced
90+
environment variable is not defined and does not have a `DEFAULT_VALUE`, it MUST
91+
be replaced with an empty value.
8992

9093
Node types MUST be interpreted after environment variable substitution takes
9194
place. This ensures the environment string representation of boolean, integer,
@@ -119,6 +122,7 @@ bool_key: ${BOOl_VALUE} # Valid reference to BOOl_
119122
int_key: ${INT_VALUE} # Valid reference to INT_VALUE
120123
float_key: ${FLOAT_VALUE} # Valid reference to FLOAT_VALUE
121124
combo_string_key: foo ${STRING_VALUE} ${FLOAT_VALUE} # Valid reference to STRING_VALUE and FLOAT_VALUE
125+
string_key_with_default: ${UNDEFINED_KEY:-fallback} # UNDEFINED_KEY is not defined but a default value is included
122126
undefined_key: ${UNDEFINED_KEY} # Invalid reference, UNDEFINED_KEY is not defined and is replaced with ""
123127
${STRING_VALUE}: value # Invalid reference, substitution is not valid in mapping keys and reference is ignored
124128
recursive_key: ${REPLACE_ME} # Valid reference to REPLACE_ME
@@ -135,6 +139,7 @@ bool_key: true # Interpreted as type bool, tag URI
135139
int_key: 1 # Interpreted as type int, tag URI tag:yaml.org,2002:int
136140
float_key: 1.1 # Interpreted as type float, tag URI tag:yaml.org,2002:float
137141
combo_string_key: foo value 1.1 # Interpreted as type string, tag URI tag:yaml.org,2002:str
142+
string_key_with_default: fallback # Interpreted as type string, tag URI tag:yaml.org,2002:str
138143
undefined_key: # Interpreted as type null, tag URI tag:yaml.org,2002:null
139144
${STRING_VALUE}: value # Interpreted as type string, tag URI tag:yaml.org,2002:str
140145
recursive_key: ${DO_NOT_REPLACE_ME} # Interpreted as type string, tag URI tag:yaml.org,2002:str

0 commit comments

Comments
 (0)