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

distro: fix auto instrumentation with otlp OTEL_TRACES_EXPORTER env var #1657

Merged
merged 8 commits into from
Mar 6, 2021
Merged
Show file tree
Hide file tree
Changes from 5 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 @@ -20,6 +20,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Renamed `BatchExportSpanProcessor` to `BatchSpanProcessor` and `SimpleExportSpanProcessor` to
`SimpleSpanProcessor`
([#1656])(https://github.com/open-telemetry/opentelemetry-python/pull/1656)
- Fixed distro configuration with `OTEL_TRACES_EXPORTER` env var set to `otlp`
([#1657])(https://github.com/open-telemetry/opentelemetry-python/pull/1657)

## [0.18b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v0.18b0) - 2021-02-16

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
15 changes: 15 additions & 0 deletions opentelemetry-distro/tests/test_configurator.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,17 @@
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,
)
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
Expand Down Expand Up @@ -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"])