diff --git a/tests/opentelemetry-docker-tests/tests/declarative_config/minimal_config.yaml b/tests/opentelemetry-docker-tests/tests/declarative_config/minimal_config.yaml new file mode 100644 index 00000000000..5aa3b2b7550 --- /dev/null +++ b/tests/opentelemetry-docker-tests/tests/declarative_config/minimal_config.yaml @@ -0,0 +1,12 @@ +file_format: "1.0" +disabled: false +resource: + attributes: + - name: "service.name" + value: "e2e-docker-test-service" +tracer_provider: + processors: + - batch: + exporter: + otlp: + endpoint: "http://localhost:4317" diff --git a/tests/opentelemetry-docker-tests/tests/declarative_config/test_otel_config_file.py b/tests/opentelemetry-docker-tests/tests/declarative_config/test_otel_config_file.py new file mode 100644 index 00000000000..6a9ed1b7b67 --- /dev/null +++ b/tests/opentelemetry-docker-tests/tests/declarative_config/test_otel_config_file.py @@ -0,0 +1,27 @@ +import os +from opentelemetry import trace +from opentelemetry.sdk._configuration import _OTelSDKConfigurator + +def test_otel_config_file_e2e(monkeypatch): + """ + Validates that setting OTEL_CONFIG_FILE properly instantiates the SDK + and exports a trace directly to the running Docker collector backend. + """ + config_path = os.path.join(os.path.dirname(__file__), "minimal_config.yaml") + + # Safely inject the configuration path environment variable into this process + monkeypatch.setenv("OTEL_CONFIG_FILE", config_path) + + # Force the configuration setup to read our new config file path + _OTelSDKConfigurator()._configure() + + # Get the configurator-initialized tracer provider and tracer instances + provider = trace.get_tracer_provider() + tracer = trace.get_tracer("e2e-test") + + # Emit a span directly to confirm no trace piping exceptions occur + with tracer.start_as_current_span("docker-plumbing-span"): + print("\nSpan emitted successfully via inline configuration parsing!") + + # Explicitly flush and close the pipeline so data hits the collector before python exits + provider.shutdown()