Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cffc016

Browse files
authored
Add protocol as an argument to the Jaeger exporter constructor (open-telemetry#978)
1 parent 76b1ed0 commit cffc016

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

exporter/opentelemetry-exporter-jaeger/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
- Change package name to opentelemetry-exporter-jaeger
66
([#953](https://github.com/open-telemetry/opentelemetry-python/pull/953))
77

8+
- Thrift URL for Jaeger exporter doesn't allow HTTPS (hardcoded to HTTP)
9+
([#978] (https://github.com/open-telemetry/opentelemetry-python/pull/978))
10+
811
## 0.8b0
912

1013
Released 2020-05-27

exporter/opentelemetry-exporter-jaeger/src/opentelemetry/exporter/jaeger/__init__.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
# collector_host_name='localhost',
4343
# collector_port=14268,
4444
# collector_endpoint='/api/traces?format=jaeger.thrift',
45+
# collector_protocol='http',
4546
# username=xxxx, # optional
4647
# password=xxxx, # optional
4748
)
@@ -77,6 +78,7 @@
7778
DEFAULT_AGENT_HOST_NAME = "localhost"
7879
DEFAULT_AGENT_PORT = 6831
7980
DEFAULT_COLLECTOR_ENDPOINT = "/api/traces?format=jaeger.thrift"
81+
DEFAULT_COLLECTOR_PROTOCOL = "http"
8082

8183
UDP_PACKET_MAX_LENGTH = 65000
8284

@@ -91,10 +93,11 @@ class JaegerSpanExporter(SpanExporter):
9193
when query for spans.
9294
agent_host_name: The host name of the Jaeger-Agent.
9395
agent_port: The port of the Jaeger-Agent.
94-
collector_host_name: The host name of the Jaeger-Collector HTTP
96+
collector_host_name: The host name of the Jaeger-Collector HTTP/HTTPS
9597
Thrift.
96-
collector_port: The port of the Jaeger-Collector HTTP Thrift.
97-
collector_endpoint: The endpoint of the Jaeger-Collector HTTP Thrift.
98+
collector_port: The port of the Jaeger-Collector HTTP/HTTPS Thrift.
99+
collector_endpoint: The endpoint of the Jaeger-Collector HTTP/HTTPS Thrift.
100+
collector_protocol: The transfer protocol for the Jaeger-Collector(HTTP or HTTPS).
98101
username: The user name of the Basic Auth if authentication is
99102
required.
100103
password: The password of the Basic Auth if authentication is
@@ -109,6 +112,7 @@ def __init__(
109112
collector_host_name=None,
110113
collector_port=None,
111114
collector_endpoint=DEFAULT_COLLECTOR_ENDPOINT,
115+
collector_protocol=DEFAULT_COLLECTOR_PROTOCOL,
112116
username=None,
113117
password=None,
114118
):
@@ -119,6 +123,7 @@ def __init__(
119123
self.collector_host_name = collector_host_name
120124
self.collector_port = collector_port
121125
self.collector_endpoint = collector_endpoint
126+
self.collector_protocol = collector_protocol
122127
self.username = username
123128
self.password = password
124129
self._collector = None
@@ -139,7 +144,8 @@ def collector(self):
139144
if self.collector_host_name is None or self.collector_port is None:
140145
return None
141146

142-
thrift_url = "http://{}:{}{}".format(
147+
thrift_url = "{}://{}:{}{}".format(
148+
self.collector_protocol,
143149
self.collector_host_name,
144150
self.collector_port,
145151
self.collector_endpoint,

exporter/opentelemetry-exporter-jaeger/tests/test_jaeger_exporter.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,15 @@ def test_constructor_default(self):
4646
thrift_port = None
4747
agent_port = 6831
4848
collector_endpoint = "/api/traces?format=jaeger.thrift"
49+
collector_protocol = "http"
4950
exporter = jaeger_exporter.JaegerSpanExporter(service_name)
5051

5152
self.assertEqual(exporter.service_name, service_name)
5253
self.assertEqual(exporter.collector_host_name, None)
5354
self.assertEqual(exporter.agent_host_name, host_name)
5455
self.assertEqual(exporter.agent_port, agent_port)
5556
self.assertEqual(exporter.collector_port, thrift_port)
57+
self.assertEqual(exporter.collector_protocol, collector_protocol)
5658
self.assertEqual(exporter.collector_endpoint, collector_endpoint)
5759
self.assertEqual(exporter.username, None)
5860
self.assertEqual(exporter.password, None)
@@ -65,6 +67,7 @@ def test_constructor_explicit(self):
6567
collector_host_name = "opentelemetry.io"
6668
collector_port = 15875
6769
collector_endpoint = "/myapi/traces?format=jaeger.thrift"
70+
collector_protocol = "https"
6871

6972
agent_port = 14268
7073
agent_host_name = "opentelemetry.io"
@@ -78,6 +81,7 @@ def test_constructor_explicit(self):
7881
collector_host_name=collector_host_name,
7982
collector_port=collector_port,
8083
collector_endpoint=collector_endpoint,
84+
collector_protocol="https",
8185
agent_host_name=agent_host_name,
8286
agent_port=agent_port,
8387
username=username,
@@ -88,6 +92,7 @@ def test_constructor_explicit(self):
8892
self.assertEqual(exporter.agent_port, agent_port)
8993
self.assertEqual(exporter.collector_host_name, collector_host_name)
9094
self.assertEqual(exporter.collector_port, collector_port)
95+
self.assertEqual(exporter.collector_protocol, collector_protocol)
9196
self.assertTrue(exporter.collector is not None)
9297
self.assertEqual(exporter.collector.auth, auth)
9398
# property should not construct new object

0 commit comments

Comments
 (0)