From 7716c8ae9ec82b8dd48185eb007f6052acb0f5db Mon Sep 17 00:00:00 2001 From: Daisuke Taniwaki Date: Fri, 19 Mar 2021 22:28:33 +0900 Subject: [PATCH 1/9] Fix get exporter names condition --- opentelemetry-distro/src/opentelemetry/distro/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opentelemetry-distro/src/opentelemetry/distro/__init__.py b/opentelemetry-distro/src/opentelemetry/distro/__init__.py index 576f44a506e..8b2f2d8ec92 100644 --- a/opentelemetry-distro/src/opentelemetry/distro/__init__.py +++ b/opentelemetry-distro/src/opentelemetry/distro/__init__.py @@ -52,7 +52,7 @@ def _get_exporter_names() -> Sequence[str]: if ( trace_exporters is not None - or trace_exporters.lower().strip() != "none" + and trace_exporters.lower().strip() != "none" ): exporters.update( { From 1a77c6ad22bf7ada532523999af53511db76a19f Mon Sep 17 00:00:00 2001 From: Daisuke Taniwaki Date: Fri, 19 Mar 2021 22:46:18 +0900 Subject: [PATCH 2/9] Add no exporters test --- opentelemetry-distro/tests/test_configurator.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/opentelemetry-distro/tests/test_configurator.py b/opentelemetry-distro/tests/test_configurator.py index fa33744deae..c6f2dfccaad 100644 --- a/opentelemetry-distro/tests/test_configurator.py +++ b/opentelemetry-distro/tests/test_configurator.py @@ -167,3 +167,7 @@ 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, {}, clear=True) + def test_no_exporters(self): + self.assertEqual(sorted(_get_exporter_names()), []) From 92d6e666d8a54f1b31dabc2a63c58ef2008a80d6 Mon Sep 17 00:00:00 2001 From: Daisuke Taniwaki Date: Fri, 19 Mar 2021 22:48:32 +0900 Subject: [PATCH 3/9] Handle empty exporters --- opentelemetry-distro/src/opentelemetry/distro/__init__.py | 1 + opentelemetry-distro/tests/test_configurator.py | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/opentelemetry-distro/src/opentelemetry/distro/__init__.py b/opentelemetry-distro/src/opentelemetry/distro/__init__.py index 8b2f2d8ec92..5285ce265ab 100644 --- a/opentelemetry-distro/src/opentelemetry/distro/__init__.py +++ b/opentelemetry-distro/src/opentelemetry/distro/__init__.py @@ -52,6 +52,7 @@ def _get_exporter_names() -> Sequence[str]: if ( trace_exporters is not None + and trace_exporters != '' and trace_exporters.lower().strip() != "none" ): exporters.update( diff --git a/opentelemetry-distro/tests/test_configurator.py b/opentelemetry-distro/tests/test_configurator.py index c6f2dfccaad..313e89e13d1 100644 --- a/opentelemetry-distro/tests/test_configurator.py +++ b/opentelemetry-distro/tests/test_configurator.py @@ -171,3 +171,7 @@ def test_multiple_exporters(self): @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()), []) From 3ce9e13f96a9665a4f9db5ba4957adb47cb2cc72 Mon Sep 17 00:00:00 2001 From: Daisuke Taniwaki Date: Fri, 19 Mar 2021 22:50:57 +0900 Subject: [PATCH 4/9] Test none exporters --- opentelemetry-distro/tests/test_configurator.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/opentelemetry-distro/tests/test_configurator.py b/opentelemetry-distro/tests/test_configurator.py index 313e89e13d1..b2d2cb46d46 100644 --- a/opentelemetry-distro/tests/test_configurator.py +++ b/opentelemetry-distro/tests/test_configurator.py @@ -168,6 +168,10 @@ def test_otlp_exporter_overwrite(self): 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()), []) From 933c492bd1ec42deac66763fc167221b7bc9a53b Mon Sep 17 00:00:00 2001 From: Daisuke Taniwaki Date: Fri, 19 Mar 2021 22:54:04 +0900 Subject: [PATCH 5/9] Update CHANGELOG --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a2ee4a62e45..acafaba8ba9 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 a parse error on no `OTEL_TRACES_EXPORTER` + ([#1707](https://github.com/open-telemetry/opentelemetry-python/pull/1707)) ### Removed - Removed unused `get_hexadecimal_trace_id` and `get_hexadecimal_span_id` methods. From 8849d0b7b201b8b6e579f4e005b99da64da52776 Mon Sep 17 00:00:00 2001 From: Daisuke Taniwaki Date: Fri, 19 Mar 2021 23:04:45 +0900 Subject: [PATCH 6/9] Fix a lint issue --- opentelemetry-distro/src/opentelemetry/distro/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opentelemetry-distro/src/opentelemetry/distro/__init__.py b/opentelemetry-distro/src/opentelemetry/distro/__init__.py index 5285ce265ab..b9a4cdebb6b 100644 --- a/opentelemetry-distro/src/opentelemetry/distro/__init__.py +++ b/opentelemetry-distro/src/opentelemetry/distro/__init__.py @@ -52,7 +52,7 @@ def _get_exporter_names() -> Sequence[str]: if ( trace_exporters is not None - and trace_exporters != '' + and trace_exporters != "" and trace_exporters.lower().strip() != "none" ): exporters.update( From 2d459fd2eb003012630562880c121456e3a622f4 Mon Sep 17 00:00:00 2001 From: Daisuke Taniwaki Date: Sat, 20 Mar 2021 11:49:44 +0900 Subject: [PATCH 7/9] Refactor the code --- opentelemetry-distro/src/opentelemetry/distro/__init__.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/opentelemetry-distro/src/opentelemetry/distro/__init__.py b/opentelemetry-distro/src/opentelemetry/distro/__init__.py index b9a4cdebb6b..818ac2c5b6d 100644 --- a/opentelemetry-distro/src/opentelemetry/distro/__init__.py +++ b/opentelemetry-distro/src/opentelemetry/distro/__init__.py @@ -51,8 +51,7 @@ def _get_exporter_names() -> Sequence[str]: exporters = set() if ( - trace_exporters is not None - and trace_exporters != "" + trace_exporters and trace_exporters.lower().strip() != "none" ): exporters.update( From 30262857b48fe00759ed3533be3d7323f08efd18 Mon Sep 17 00:00:00 2001 From: Daisuke Taniwaki Date: Sat, 20 Mar 2021 16:25:26 +0900 Subject: [PATCH 8/9] Fix the changelog sentence --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index acafaba8ba9..25741bf98b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -68,7 +68,7 @@ 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 a parse error on no `OTEL_TRACES_EXPORTER` +- Fixed an unset `OTEL_TRACES_EXPORTER` resulting in an error ([#1707](https://github.com/open-telemetry/opentelemetry-python/pull/1707)) ### Removed From bc9ef32f2b5f5442518554e331fc50ad1bfc4f27 Mon Sep 17 00:00:00 2001 From: Daisuke Taniwaki Date: Sat, 20 Mar 2021 16:26:33 +0900 Subject: [PATCH 9/9] Fix a lint issue --- opentelemetry-distro/src/opentelemetry/distro/__init__.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/opentelemetry-distro/src/opentelemetry/distro/__init__.py b/opentelemetry-distro/src/opentelemetry/distro/__init__.py index 818ac2c5b6d..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 - and trace_exporters.lower().strip() != "none" - ): + if trace_exporters and trace_exporters.lower().strip() != "none": exporters.update( { trace_exporter.strip()