diff --git a/CHANGELOG.md b/CHANGELOG.md index 81c56db3798..47db7726653 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ([#1656])(https://github.com/open-telemetry/opentelemetry-python/pull/1656) - Rename `DefaultSpan` to `NonRecordingSpan` ([#1661])(https://github.com/open-telemetry/opentelemetry-python/pull/1661) +- Fixed distro configuration with `OTEL_TRACES_EXPORTER` env var set to `otlp` + ([#1657])(https://github.com/open-telemetry/opentelemetry-python/pull/1657) - Moving `Getter`, `Setter` and `TextMapPropagator` out of `opentelemetry.trace.propagation` and into `opentelemetry.propagators` ([#1662])(https://github.com/open-telemetry/opentelemetry-python/pull/1662) diff --git a/opentelemetry-distro/src/opentelemetry/distro/__init__.py b/opentelemetry-distro/src/opentelemetry/distro/__init__.py index 666ab57bb37..6496be16c5b 100644 --- a/opentelemetry-distro/src/opentelemetry/distro/__init__.py +++ b/opentelemetry-distro/src/opentelemetry/distro/__init__.py @@ -67,7 +67,7 @@ def _get_exporter_names() -> Sequence[str]: ) if EXPORTER_OTLP in exporters: - exporters.pop(EXPORTER_OTLP) + exporters.remove(EXPORTER_OTLP) exporters.add(EXPORTER_OTLP_SPAN) return list(exporters) diff --git a/opentelemetry-distro/tests/test_configurator.py b/opentelemetry-distro/tests/test_configurator.py index 91ca82da86f..899e019113c 100644 --- a/opentelemetry-distro/tests/test_configurator.py +++ b/opentelemetry-distro/tests/test_configurator.py @@ -18,6 +18,9 @@ from unittest.mock import patch from opentelemetry.distro import ( + EXPORTER_OTLP, + EXPORTER_OTLP_SPAN, + _get_exporter_names, _get_id_generator, _import_id_generator, _init_tracing, @@ -25,6 +28,7 @@ from opentelemetry.environment_variables import ( OTEL_PYTHON_ID_GENERATOR, OTEL_PYTHON_SERVICE_NAME, + OTEL_TRACES_EXPORTER, ) from opentelemetry.sdk.resources import Resource from opentelemetry.sdk.trace.id_generator import IdGenerator, RandomIdGenerator @@ -143,3 +147,14 @@ def test_trace_init_custom_id_generator(self, mock_iter_entry_points): _init_tracing({}, id_generator) provider = self.set_provider_mock.call_args[0][0] self.assertIsInstance(provider.id_generator, CustomIdGenerator) + + +class TestExporterNames(TestCase): + def test_otlp_exporter_overwrite(self): + for exporter in [EXPORTER_OTLP, EXPORTER_OTLP_SPAN]: + with patch.dict(environ, {OTEL_TRACES_EXPORTER: exporter}): + self.assertEqual(_get_exporter_names(), [EXPORTER_OTLP_SPAN]) + + @patch.dict(environ, {OTEL_TRACES_EXPORTER: "jaeger,zipkin"}) + def test_multiple_exporters(self): + self.assertEqual(sorted(_get_exporter_names()), ["jaeger", "zipkin"])