Skip to content

Commit

Permalink
Define OTEL_EXPERIMENTAL_CONFIG_FILE to ignore other env vars, add en…
Browse files Browse the repository at this point in the history
…v var substitution default syntax (open-telemetry#3948)

Fixes open-telemetry#3752.

Implementation of the configuration working group recommendation as
[described
here](open-telemetry#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.
  • Loading branch information
jack-berg authored Apr 5, 2024
1 parent 97b7702 commit 1f8556e
Show file tree
Hide file tree
Showing 3 changed files with 116 additions and 62 deletions.
63 changes: 32 additions & 31 deletions spec-compliance-matrix.md
Original file line number Diff line number Diff line change
Expand Up @@ -269,37 +269,38 @@ Disclaimer: this list of features is still a work in progress, please refer to t

Note: Support for environment variables is optional.

| Feature | Go | Java | JS | Python | Ruby | Erlang | PHP | Rust | C++ | .NET | Swift |
|----------------------------------------------------------|-----|------|-----|-------------|------|--------|-----|------|-----|------|-------|
| OTEL_SDK_DISABLED | - | + | - | - | - | - | + | - | - | - | - |
| OTEL_RESOURCE_ATTRIBUTES | + | + | + | + | + | + | + | + | + | + | - |
| OTEL_SERVICE_NAME | + | + | + | + | + | + | + | | + | + | |
| OTEL_LOG_LEVEL | - | - | + | [-][py1059] | + | - | + | | - | - | - |
| OTEL_PROPAGATORS | - | + | | + | + | + | + | - | - | - | - |
| OTEL_BSP_* | + | + | + | + | + | + | + | + | - | + | - |
| OTEL_BLRP_* | | + | | | | | | + | | + | |
| OTEL_EXPORTER_OTLP_* | + | + | | + | + | + | + | + | + | + | - |
| OTEL_EXPORTER_ZIPKIN_* | - | + | | + | + | - | + | - | - | + | - |
| OTEL_TRACES_EXPORTER | - | + | + | + | + | + | + | - | - | - | |
| OTEL_METRICS_EXPORTER | - | + | | + | - | - | + | - | - | - | - |
| OTEL_LOGS_EXPORTER | - | + | | + | | | + | | | - | |
| OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT | + | + | + | + | + | + | + | + | - | + | |
| OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT | + | + | + | + | + | + | + | | | + | |
| OTEL_SPAN_EVENT_COUNT_LIMIT | + | + | + | + | + | + | + | + | - | + | |
| OTEL_SPAN_LINK_COUNT_LIMIT | + | + | + | + | + | + | + | + | - | + | |
| OTEL_EVENT_ATTRIBUTE_COUNT_LIMIT | + | - | | + | + | + | + | | | + | |
| OTEL_LINK_ATTRIBUTE_COUNT_LIMIT | + | - | | + | + | + | + | | | + | |
| OTEL_LOGRECORD_ATTRIBUTE_COUNT_LIMIT | | | | | | | + | | | | |
| OTEL_LOGRECORD_ATTRIBUTE_VALUE_LENGTH_LIMIT | | | | | | | + | | | | |
| OTEL_TRACES_SAMPLER | + | + | + | + | + | + | + | - | - | - | |
| OTEL_TRACES_SAMPLER_ARG | + | + | + | + | + | + | + | - | - | - | |
| OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT | + | + | + | + | + | - | + | | | + | |
| OTEL_ATTRIBUTE_COUNT_LIMIT | + | + | + | + | + | - | + | | | + | |
| OTEL_METRIC_EXPORT_INTERVAL | - | + | | | | | + | | | + | |
| OTEL_METRIC_EXPORT_TIMEOUT | - | - | | | | | + | | | + | |
| OTEL_METRICS_EXEMPLAR_FILTER | - | + | | | | | + | | | - | |
| OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE | - | + | + | + | | | + | | | + | |
| OTEL_EXPORTER_OTLP_METRICS_DEFAULT_HISTOGRAM_AGGREGATION | | + | | | | | | | | | |
| Feature | Go | Java | JS | Python | Ruby | Erlang | PHP | Rust | C++ | .NET | Swift |
|----------------------------------------------------------|----|------|----|-------------|------|--------|-----|------|-----|------|-------|
| OTEL_SDK_DISABLED | - | + | - | - | - | - | + | - | - | - | - |
| OTEL_RESOURCE_ATTRIBUTES | + | + | + | + | + | + | + | + | + | + | - |
| OTEL_SERVICE_NAME | + | + | + | + | + | + | + | | + | + | |
| OTEL_LOG_LEVEL | - | - | + | [-][py1059] | + | - | + | | - | - | - |
| OTEL_PROPAGATORS | - | + | | + | + | + | + | - | - | - | - |
| OTEL_BSP_* | + | + | + | + | + | + | + | + | - | + | - |
| OTEL_BLRP_* | | + | | | | | | + | | + | |
| OTEL_EXPORTER_OTLP_* | + | + | | + | + | + | + | + | + | + | - |
| OTEL_EXPORTER_ZIPKIN_* | - | + | | + | + | - | + | - | - | + | - |
| OTEL_TRACES_EXPORTER | - | + | + | + | + | + | + | - | - | - | |
| OTEL_METRICS_EXPORTER | - | + | | + | - | - | + | - | - | - | - |
| OTEL_LOGS_EXPORTER | - | + | | + | | | + | | | - | |
| OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT | + | + | + | + | + | + | + | + | - | + | |
| OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT | + | + | + | + | + | + | + | | | + | |
| OTEL_SPAN_EVENT_COUNT_LIMIT | + | + | + | + | + | + | + | + | - | + | |
| OTEL_SPAN_LINK_COUNT_LIMIT | + | + | + | + | + | + | + | + | - | + | |
| OTEL_EVENT_ATTRIBUTE_COUNT_LIMIT | + | - | | + | + | + | + | | | + | |
| OTEL_LINK_ATTRIBUTE_COUNT_LIMIT | + | - | | + | + | + | + | | | + | |
| OTEL_LOGRECORD_ATTRIBUTE_COUNT_LIMIT | | | | | | | + | | | | |
| OTEL_LOGRECORD_ATTRIBUTE_VALUE_LENGTH_LIMIT | | | | | | | + | | | | |
| OTEL_TRACES_SAMPLER | + | + | + | + | + | + | + | - | - | - | |
| OTEL_TRACES_SAMPLER_ARG | + | + | + | + | + | + | + | - | - | - | |
| OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT | + | + | + | + | + | - | + | | | + | |
| OTEL_ATTRIBUTE_COUNT_LIMIT | + | + | + | + | + | - | + | | | + | |
| OTEL_METRIC_EXPORT_INTERVAL | - | + | | | | | + | | | + | |
| OTEL_METRIC_EXPORT_TIMEOUT | - | - | | | | | + | | | + | |
| OTEL_METRICS_EXEMPLAR_FILTER | - | + | | | | | + | | | - | |
| OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE | - | + | + | + | | | + | | | + | |
| OTEL_EXPORTER_OTLP_METRICS_DEFAULT_HISTOGRAM_AGGREGATION | | + | | | | | | | | | |
| OTEL_EXPERIMENTAL_CONFIG_FILE | | | | | | | | | | | |

## File Configuration

Expand Down
11 changes: 8 additions & 3 deletions specification/configuration/file-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Configuration files support environment variables substitution for references
which match the following regular expression:

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

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

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

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

0 comments on commit 1f8556e

Please sign in to comment.