OpenTelemetry Certified Associate (OTCA) free question 7 / 10 · Domain 3: The OpenTelemetry Collector
A team wants the Collector to read its configuration from an environment variable instead of a file. How can they pass it with the --config option?
- Pass the variable name as a plain value, which the Collector resolves on its own
- Pass a config URI that uses the yaml scheme, followed by the variable name
- Pass a config URI that uses the env scheme, followed by the name of the variable
- Pass the variable through --set, which loads a complete configuration from it
Show the answer and explanation
Answer: C
Why this is correct
The --config option accepts either a file path or a config URI of the form <scheme>:<opaque_data>. The supported providers include file, env, yaml, http and https, and the env provider reads the configuration from an environment variable, for example env:MY_CONFIG_IN_AN_ENVVAR. Using the scheme tells the Collector where to look; without it the value is treated as a path.
Why the other options are wrong
"Pass the variable name as a plain value, which the Collector resolves on its own" … A plain value is taken as a file path, so the variable name would be read as a file name. Reading from the environment needs the env scheme.
"Pass the variable through --set, which loads a complete configuration from it" … The --set option overrides individual settings key by key after the --config sources are resolved. It does not load a configuration.
"Pass a config URI that uses the yaml scheme, followed by the variable name" … The yaml scheme reads configuration from a YAML string given inline, with :: separating subpaths. The env scheme reads an environment variable.
Key points
Config URI schemes: file, env, yaml, http, https. Without a scheme the value is a file path.