Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix get exporter names condition #1707

Merged
merged 9 commits into from
Mar 22, 2021
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you change the description to be focused on the behavior of the user?

In this case, I would expect something like Fixed an unset OTEL_TRACES_EXPORTER resulting in an error.

This way a reader can identify whether their behavior is fixed or not.

([#1707](https://github.com/open-telemetry/opentelemetry-python/pull/1707))

### Removed
- Removed unused `get_hexadecimal_trace_id` and `get_hexadecimal_span_id` methods.
Expand Down
3 changes: 2 additions & 1 deletion opentelemetry-distro/src/opentelemetry/distro/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ def _get_exporter_names() -> Sequence[str]:

if (
trace_exporters is not None
or trace_exporters.lower().strip() != "none"
and trace_exporters != ""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we just do if trace_exporters and trace_exporters.lower().strip() != "none"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's right. 👍

and trace_exporters.lower().strip() != "none"
):
exporters.update(
{
Expand Down
12 changes: 12 additions & 0 deletions opentelemetry-distro/tests/test_configurator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()), [])