diff --git a/CHANGELOG.md b/CHANGELOG.md index a2ee4a62e45..25741bf98b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -68,6 +68,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ([#1695](https://github.com/open-telemetry/opentelemetry-python/pull/1695)) - Change Jaeger exporters to obtain service.name from span ([#1703](https://github.com/open-telemetry/opentelemetry-python/pull/1703)) +- Fixed an unset `OTEL_TRACES_EXPORTER` resulting in an error + ([#1707](https://github.com/open-telemetry/opentelemetry-python/pull/1707)) ### Removed - Removed unused `get_hexadecimal_trace_id` and `get_hexadecimal_span_id` methods. diff --git a/opentelemetry-distro/src/opentelemetry/distro/__init__.py b/opentelemetry-distro/src/opentelemetry/distro/__init__.py index 576f44a506e..258bdaddc55 100644 --- a/opentelemetry-distro/src/opentelemetry/distro/__init__.py +++ b/opentelemetry-distro/src/opentelemetry/distro/__init__.py @@ -50,10 +50,7 @@ def _get_exporter_names() -> Sequence[str]: exporters = set() - if ( - trace_exporters is not None - or trace_exporters.lower().strip() != "none" - ): + if trace_exporters and trace_exporters.lower().strip() != "none": exporters.update( { trace_exporter.strip() diff --git a/opentelemetry-distro/tests/test_configurator.py b/opentelemetry-distro/tests/test_configurator.py index fa33744deae..b2d2cb46d46 100644 --- a/opentelemetry-distro/tests/test_configurator.py +++ b/opentelemetry-distro/tests/test_configurator.py @@ -167,3 +167,15 @@ def test_otlp_exporter_overwrite(self): @patch.dict(environ, {OTEL_TRACES_EXPORTER: "jaeger,zipkin"}) def test_multiple_exporters(self): self.assertEqual(sorted(_get_exporter_names()), ["jaeger", "zipkin"]) + + @patch.dict(environ, {OTEL_TRACES_EXPORTER: "none"}) + def test_none_exporters(self): + self.assertEqual(sorted(_get_exporter_names()), []) + + @patch.dict(environ, {}, clear=True) + def test_no_exporters(self): + self.assertEqual(sorted(_get_exporter_names()), []) + + @patch.dict(environ, {OTEL_TRACES_EXPORTER: ""}) + def test_empty_exporters(self): + self.assertEqual(sorted(_get_exporter_names()), [])