Motivation
#5271 wires OTEL_CONFIG_FILE through _OTelSDKConfigurator._configure so the SDK loads and applies a declarative YAML/JSON file when the env var is set. The unit tests in tests/_configuration/test_configurator_file_routing.py cover the routing logic in isolation (mocked _initialize_components, configure_sdk, load_config_file), but nothing exercises the full path against a real running collector.
Picked up from @xrmx's review:
LGTM, what do you think of adding a test in a followup PR (in docker-tests?) to check that the plumbing is working e2e?
Proposed test shape
Add a new subdirectory under tests/opentelemetry-docker-tests/tests/ (alongside otlpexporter/ and opencensus/) that:
- Reuses the existing OTLP collector container from
docker-compose.yml.
- Writes a minimal declarative config YAML pointing the OTLP span exporter at the collector endpoint.
- Launches a Python process with
OTEL_CONFIG_FILE=/path/to/that.yaml (and no other OTEL_* vars), instantiates _OTelSDKConfigurator(), emits a span via the global tracer, and shuts down.
- Asserts the collector received the expected span.
This proves the chain: env-var detection → load_config_file → schema validation → _dict_to_dataclass → configure_sdk → per-signal factories → OTLP exporter → wire.
Useful follow-ons in the same suite:
- Same for metric and log signals.
- Negative path: invalid YAML → process exits non-zero with
ConfigurationError.
- Env-var fallback:
OTEL_CONFIG_FILE unset + OTEL_TRACES_EXPORTER=otlp still works (verifies the routing doesn't break the existing env-var path).
Related
Refs #3631
Motivation
#5271 wires
OTEL_CONFIG_FILEthrough_OTelSDKConfigurator._configureso the SDK loads and applies a declarative YAML/JSON file when the env var is set. The unit tests intests/_configuration/test_configurator_file_routing.pycover the routing logic in isolation (mocked_initialize_components,configure_sdk,load_config_file), but nothing exercises the full path against a real running collector.Picked up from @xrmx's review:
Proposed test shape
Add a new subdirectory under
tests/opentelemetry-docker-tests/tests/(alongsideotlpexporter/andopencensus/) that:docker-compose.yml.OTEL_CONFIG_FILE=/path/to/that.yaml(and no otherOTEL_*vars), instantiates_OTelSDKConfigurator(), emits a span via the global tracer, and shuts down.This proves the chain: env-var detection →
load_config_file→ schema validation →_dict_to_dataclass→configure_sdk→ per-signal factories → OTLP exporter → wire.Useful follow-ons in the same suite:
ConfigurationError.OTEL_CONFIG_FILEunset +OTEL_TRACES_EXPORTER=otlpstill works (verifies the routing doesn't break the existing env-var path).Related
OTEL_CONFIG_FILE(the change this test covers)Refs #3631