Spec-compliant typed reads of OTEL_* environment variables.
Implements the value-parsing semantics from
configuration/sdk-environment-variables.md L48-L107 (parse rules)
and configuration/common.md L77-L102 (Duration / Timeout).
All readers return nil when the variable is unset or when its
value fails to parse — and emit a Logger.warning per the spec
guidance attached to each parse rule. Callers treat nil as
"fall through to the next layer" (Application env → built-in
default), giving a clean three-layer composition.
Public API
| Function | Spec rule |
|---|---|
string/1 | L60 — empty value MUST be treated as unset |
boolean/1 | L66-L76 — only case-insensitive "true" is true |
integer/1 | L88-L90 — SHOULD warn + treat as unset on unparseable |
duration_ms/1 | common.md L77-L82 — non-negative milliseconds |
timeout_ms/1 | common.md L92-L102 — 0 SHOULD mean infinite |
enum/2 | L103-L107 — case-insensitive; unknown MUST warn + ignore |
list/1 | comma-separated; empty entries dropped |
References
- OTel SDK env vars:
opentelemetry-specification/specification/configuration/sdk-environment-variables.md - OTel SDK common:
opentelemetry-specification/specification/configuration/common.md
Summary
Functions
Reads var as a boolean. Spec L66-L76 — only case-insensitive
"true" is true; everything else is false. Unparseable values
fall to false with a warning.
Reads var as a Duration in milliseconds. common.md L77-L82 —
non-negative milliseconds. Negative values warn and are ignored.
Reads var as an enum, matching its lowercased value against the
allowed atoms (compared by their Atom.to_string/1 form). Spec
L103-L107 — unknown values MUST warn and be ignored.
Reads var as an integer. Spec L88-L90 — unparseable values SHOULD
warn and be treated as unset.
Reads var as a comma-separated list of trimmed, non-empty
strings. Returns nil when the variable is unset.
Reads var as a string. Spec L60 — empty value MUST be unset.
Reads var as a Timeout in milliseconds. common.md L92-L102 —
0 SHOULD mean no limit (returned as :infinity).
Functions
Reads var as a boolean. Spec L66-L76 — only case-insensitive
"true" is true; everything else is false. Unparseable values
fall to false with a warning.
@spec duration_ms(var :: String.t()) :: non_neg_integer() | nil
Reads var as a Duration in milliseconds. common.md L77-L82 —
non-negative milliseconds. Negative values warn and are ignored.
Reads var as an enum, matching its lowercased value against the
allowed atoms (compared by their Atom.to_string/1 form). Spec
L103-L107 — unknown values MUST warn and be ignored.
Reads var as an integer. Spec L88-L90 — unparseable values SHOULD
warn and be treated as unset.
Reads var as a comma-separated list of trimmed, non-empty
strings. Returns nil when the variable is unset.
Note: spec L118 mandates dedup only for OTEL_PROPAGATORS; this
helper does not dedup — call sites that need it must do so.
Reads var as a string. Spec L60 — empty value MUST be unset.
@spec timeout_ms(var :: String.t()) :: non_neg_integer() | :infinity | nil
Reads var as a Timeout in milliseconds. common.md L92-L102 —
0 SHOULD mean no limit (returned as :infinity).