Repository: open-telemetry/opentelemetry-python

Issue:
Thrift URL for Jaeger exporter doesn't allow HTTPS (hardcoded to HTTP)
I'm currently not able to export logs to collectors running over HTTPS unless I overwrite the collector property and change the thrift url string. 

https://github.com/open-telemetry/opentelemetry-python/blob/1112792b18bb177ba58fa11ebaecc9597041a73c/exporter/opentelemetry-exporter-jaeger/src/opentelemetry/exporter/jaeger/__init__.py#L142

Can the scheme (http vs https) be an parameter of the exporter's __init__ method?


Discussion:

Resolving patch:
diff --git a/exporter/opentelemetry-exporter-jaeger/src/opentelemetry/exporter/jaeger/__init__.py b/exporter/opentelemetry-exporter-jaeger/src/opentelemetry/exporter/jaeger/__init__.py
--- a/exporter/opentelemetry-exporter-jaeger/src/opentelemetry/exporter/jaeger/__init__.py
+++ b/exporter/opentelemetry-exporter-jaeger/src/opentelemetry/exporter/jaeger/__init__.py
@@ -42,6 +42,7 @@
         # collector_host_name='localhost',
         # collector_port=14268,
         # collector_endpoint='/api/traces?format=jaeger.thrift',
+        # collector_protocol='http',
         # username=xxxx, # optional
         # password=xxxx, # optional
     )
@@ -77,6 +78,7 @@
 DEFAULT_AGENT_HOST_NAME = "localhost"
 DEFAULT_AGENT_PORT = 6831
 DEFAULT_COLLECTOR_ENDPOINT = "/api/traces?format=jaeger.thrift"
+DEFAULT_COLLECTOR_PROTOCOL = "http"
 
 UDP_PACKET_MAX_LENGTH = 65000
 
@@ -91,10 +93,11 @@ class JaegerSpanExporter(SpanExporter):
             when query for spans.
         agent_host_name: The host name of the Jaeger-Agent.
         agent_port: The port of the Jaeger-Agent.
-        collector_host_name: The host name of the Jaeger-Collector HTTP
+        collector_host_name: The host name of the Jaeger-Collector HTTP/HTTPS
             Thrift.
-        collector_port: The port of the Jaeger-Collector HTTP Thrift.
-        collector_endpoint: The endpoint of the Jaeger-Collector HTTP Thrift.
+        collector_port: The port of the Jaeger-Collector HTTP/HTTPS Thrift.
+        collector_endpoint: The endpoint of the Jaeger-Collector HTTP/HTTPS Thrift.
+        collector_protocol: The transfer protocol for the Jaeger-Collector(HTTP or HTTPS).
         username: The user name of the Basic Auth if authentication is
             required.
         password: The password of the Basic Auth if authentication is
@@ -109,6 +112,7 @@ def __init__(
         collector_host_name=None,
         collector_port=None,
         collector_endpoint=DEFAULT_COLLECTOR_ENDPOINT,
+        collector_protocol=DEFAULT_COLLECTOR_PROTOCOL,
         username=None,
         password=None,
     ):
@@ -119,6 +123,7 @@ def __init__(
         self.collector_host_name = collector_host_name
         self.collector_port = collector_port
         self.collector_endpoint = collector_endpoint
+        self.collector_protocol = collector_protocol
         self.username = username
         self.password = password
         self._collector = None
@@ -139,7 +144,8 @@ def collector(self):
         if self.collector_host_name is None or self.collector_port is None:
             return None
 
-        thrift_url = "http://{}:{}{}".format(
+        thrift_url = "{}://{}:{}{}".format(
+            self.collector_protocol,
             self.collector_host_name,
             self.collector_port,
             self.collector_endpoint,


Test patch:
diff --git a/exporter/opentelemetry-exporter-jaeger/tests/test_jaeger_exporter.py b/exporter/opentelemetry-exporter-jaeger/tests/test_jaeger_exporter.py
--- a/exporter/opentelemetry-exporter-jaeger/tests/test_jaeger_exporter.py
+++ b/exporter/opentelemetry-exporter-jaeger/tests/test_jaeger_exporter.py
@@ -46,6 +46,7 @@ def test_constructor_default(self):
         thrift_port = None
         agent_port = 6831
         collector_endpoint = "/api/traces?format=jaeger.thrift"
+        collector_protocol = "http"
         exporter = jaeger_exporter.JaegerSpanExporter(service_name)
 
         self.assertEqual(exporter.service_name, service_name)
@@ -53,6 +54,7 @@ def test_constructor_default(self):
         self.assertEqual(exporter.agent_host_name, host_name)
         self.assertEqual(exporter.agent_port, agent_port)
         self.assertEqual(exporter.collector_port, thrift_port)
+        self.assertEqual(exporter.collector_protocol, collector_protocol)
         self.assertEqual(exporter.collector_endpoint, collector_endpoint)
         self.assertEqual(exporter.username, None)
         self.assertEqual(exporter.password, None)
@@ -65,6 +67,7 @@ def test_constructor_explicit(self):
         collector_host_name = "opentelemetry.io"
         collector_port = 15875
         collector_endpoint = "/myapi/traces?format=jaeger.thrift"
+        collector_protocol = "https"
 
         agent_port = 14268
         agent_host_name = "opentelemetry.io"
@@ -78,6 +81,7 @@ def test_constructor_explicit(self):
             collector_host_name=collector_host_name,
             collector_port=collector_port,
             collector_endpoint=collector_endpoint,
+            collector_protocol="https",
             agent_host_name=agent_host_name,
             agent_port=agent_port,
             username=username,
@@ -88,6 +92,7 @@ def test_constructor_explicit(self):
         self.assertEqual(exporter.agent_port, agent_port)
         self.assertEqual(exporter.collector_host_name, collector_host_name)
         self.assertEqual(exporter.collector_port, collector_port)
+        self.assertEqual(exporter.collector_protocol, collector_protocol)
         self.assertTrue(exporter.collector is not None)
         self.assertEqual(exporter.collector.auth, auth)
         # property should not construct new object