open-telemetry / opentelemetry-specification

Specifications for OpenTelemetry
https://opentelemetry.io
Apache License 2.0
3.65k stars 875 forks source link

Clarify the precedence of environment variables over application-local configuration #1171

Open chgl opened 3 years ago

chgl commented 3 years ago

What are you trying to achieve?

Should OTEL configuration options set via environment variables take precedence over configuration "hard-coded" inside the application?

Additional context.

This came up in https://github.com/open-telemetry/opentelemetry-js/pull/1566. The spec for environment variables currently does not specify precedence.

There's some inconsistency between the SDKs: Env vars take precedence in the Java SDK over system properties, whereas the JavaScript SDK's local config overrides env vars.

Is this something the specification should comment on or is it up to the developers/conventions of the language?

Oberon00 commented 3 years ago

Relatedly, how & when should the default values for env vars apply? See also open-telemetry/opentelemetry.io#4348

cbandy commented 3 years ago

This issue seems like another reason to provide functionality in the SDK rather than do it automatically there; see https://github.com/open-telemetry/opentelemetry-specification/issues/1193#issuecomment-721838857.

Is this something the specification should comment on or is it up to the developers/conventions of the language?

In my experience, the precedence of environment variables falls between command-line flags and configuration files, both of which are outside the scope of the specification (if I understand correctly).