Skip to content

Commit cc51928

Browse files
author
alrex
authored
fix otlp grpc exporter bug when no scheme is passed in (open-telemetry#1806)
1 parent 300ce1b commit cc51928

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

CHANGELOG.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77
## [Unreleased](https://github.com/open-telemetry/opentelemetry-python/compare/v1.1.0...HEAD)
88

99
### Added
10-
- Added example for running Django with auto instrumentation
10+
- Added example for running Django with auto instrumentation.
1111
([#1803](https://github.com/open-telemetry/opentelemetry-python/pull/1803))
1212

13+
### Changed
14+
- Fixed OTLP gRPC exporter silently failing if scheme is not specified in endpoint.
15+
([#1806](https://github.com/open-telemetry/opentelemetry-python/pull/1806))
16+
1317
### Removed
14-
- Moved `opentelemetry-instrumentation` to contrib repository
18+
- Moved `opentelemetry-instrumentation` to contrib repository.
1519
([#1797](https://github.com/open-telemetry/opentelemetry-python/pull/1797))
1620

1721
## [1.1.0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.1.0) - 2021-04-20

exporter/opentelemetry-exporter-otlp-proto-grpc/src/opentelemetry/exporter/otlp/proto/grpc/exporter.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,8 @@ def __init__(
207207
else:
208208
insecure = True
209209

210-
endpoint = parsed_url.netloc
210+
if parsed_url.netloc:
211+
endpoint = parsed_url.netloc
211212

212213
self._headers = headers or environ.get(OTEL_EXPORTER_OTLP_HEADERS)
213214
if isinstance(self._headers, str):

exporter/opentelemetry-exporter-otlp-proto-grpc/tests/test_otlp_trace_exporter.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ def test_otlp_headers_from_env(self, mock_ssl_channel, mock_secure):
239239
@patch("opentelemetry.exporter.otlp.proto.grpc.exporter.secure_channel")
240240
def test_otlp_exporter_endpoint(self, mock_secure, mock_insecure):
241241
"""Just OTEL_EXPORTER_OTLP_COMPRESSION should work"""
242+
expected_endpoint = "localhost:4317"
242243
endpoints = [
243244
(
244245
"http://localhost:4317",
@@ -275,6 +276,13 @@ def test_otlp_exporter_endpoint(self, mock_secure, mock_insecure):
275276
mock_method, endpoint, insecure
276277
),
277278
)
279+
self.assertEqual(
280+
expected_endpoint,
281+
mock_method.call_args[0][0],
282+
"expected {} got {} {}".format(
283+
expected_endpoint, mock_method.call_args[0][0], endpoint
284+
),
285+
)
278286
mock_method.reset_mock()
279287

280288
# pylint: disable=no-self-use

0 commit comments

Comments
 (0)